Cocos2dx-lua Binding Code Editor

Source: Internet
Author: User
Tags lua python script sublime text

Turn from: http://blog.csdn.net/wtyqm/article/details/9346863

Enjoy the benefits of scripting language flexibility, ease of updating, and freedom from compilation, but you can't tolerate leaving those handy IDE features (jump, AutoComplete).

Collection and collation of some use sublime text editing Cocos2dx-lua project information, hope to bring help to everyone.


One, automatic completion (auto-completion)

A. The words that have been entered

The word entered in this document, ST (sublime text) will give a full hint. This is even stronger than most ides (usually only gives symbolic hints, not prompt for plain text such as strings)


B. Cross-file function calls

Cross-file text hints, St need plugin support. The current use of a plug-in mysignatureplugin, supporting the function of the cross-file completion, prompt parameter information. This plugin has only one Python source file, more than 100 lines of code. Originally only support JS. I did some minor modifications to it with LUA support cocos2dx-lua-tools/mysign.py


C.COCOS2DX API, Custom API

Some of the exported COCOS2DX APIs are often invoked in scripts, or some of our custom C + + extension APIs

Cocos2d_lua_snippets, this plugin generates a bunch of St Snippet (code Snippets) through the COCOS2DX tolua++ pkg file, which achieves the purpose of the automatic prompt API

Generating scripts I have also made some changes to it: A. Exporting enumeration definitions in PKG files B. Non-static function, not complement full class name when auto complement


Brief introduction of D.St complement mechanism

The above several complementary methods make full use of the complement extension mechanism provided by St. The full option is considered in the following order when St completion

A.snippet (Code fragment): Specifies the mapping of keywords to a large segment of code, each snippet to be stored as a separate file. Cocos2d_lua_snippets is using this approach.

The b.api-injected Completions:python plug-in can register the callback function and return the possible completion options, which can be logical and more flexible. Mysignatureplugin is using this approach.

C.completion file: I understand that a file is used to store a large number of short snippet. I wrote the COCOS2DX enumeration value complement in this way

D.buffer: Is the St. with the complete word of this document


E. Deficiencies

The above complement method, which is simply a text-level match, cannot be used to restrict the completion of the content based on the current context, as the IDE does with the static language. It seems that the intelligent perception of dynamic language, this is more difficult, the type of a variable, is often run only can know, and can be changed.

In a post that discusses the LUA editor complement, I see a reply from a glider (a business Lua IDE) employee. As if they were using a LUA virtual machine built into the editor, they could achieve more powerful complementary functionality.

St side, more potential, more powerful heavyweight plug-ins are:

Sublimecodeintel, completion

But neither of these plug-ins supports LUA at the moment, and the amount of code is relatively large and not easy to modify.

The same is the dynamic language of JS, this support is much better, in addition to the above mentioned Sublimecodeintel, even Visual Studio has provided to JS IntelliSense. Compared to a large number of applications of JS Web development, a large number of application of LUA game development can only be said to be a little brother. If not for the well-designed Lua language has a good opinion, can not put it's coroutine mechanism, I would like to use the COCOS2DX directly in the JS binding more convenient (a few Zynga foreigners do their best to make JS binding, resulting in many aspects of JS binding has been leading LUA binding)


Second, jump

Here we recommend the sublime Text 3 jump function. In addition to inheriting the second generation of the file within the symbol jump, the third generation is added to the inter-file symbol jump

Feel St symbol jump, more usable than IDE's function, full keyboard operation, preview-return, who used to know

However, ST3 jumps between the files does not seem to support previewing-return


Help:

In the GitHub see good warehouse, I am not sure will be modified, will generally choose the clone operation. But this should be changed in the future, unlike fork, you can pull request, it is difficult to contribute code. Whether or not to modify, directly fork words, feeling again a bit heavy. I do not know if there are other operating procedures.

--------------------------------------------------------------------------------------------------------------- -------------------

3/F Meteoric_cry 2013-07-29 18:01 post [Reply] function abc::aa ()

End

Input ABC has the hint "ABC::AA", but after entering the carriage return, the ABC does not have, only enters the AA re:wtyqm 2013-07-29 19:12 to publish [Reply] reply meteoric_cry: You mean the function that you define in Lua, or the COCOS2DX API. If the latter, the use of my modified plug-ins, the effect is static function complement into class name: function name form, not static function only complement full function name 2 floor chinesetree2013 2013-07-18 20:15 [Reply] Find a long time to find the landlord this article, Very moved, in the learning cocos2dx Lua part, find a useful editor to find me a good hard.
After reading the landlord's article, try it, cross file function This can not get up, use JS to do not. I hope that the details of the landlord Big Brother RE:WTYQM 2013-07-18 21:17 [Reply] reply u011446040: The plug-in called across files, you need to drag your LUA source code directory into St. Then save the disk, it is every time the file, analysis Open Directory in all the files in the function signature. Still can't get words, can view->show console, see if there is anything wrong happened re:chinesetree2013 2013-07-19 09:43 published [Reply] reply wtyqm: Thank you landlord reply.
The Cocos2d API has several small puzzles when it comes to automatic completion:
1. For example ccdirector this keyword, must use the capitalization to hit "CC" Ability, dozen "CC" will not eject the complete prompt, this kind of situation is normal.
2. When obtaining Visiblesize, the API's complement is ccdirector:getvisiblesize ()
This operation will be an error, the correct should be Ccdirector:shareddirector (): Getvisiblesize (), and I entered the "Ccdirector_sh" will be completed Ccdirector:shareddirector There is no way to go on with the completion. I would like to ask the landlord is the case when used.
3.COCOS2DX engine is often updated, how to generate snippet by pkg, principle or method landlord can share it. RE:WTYQM 2013-07-20 10:09 [Reply] Reply U011446040:1.cocos2d API complement this plug-in, using the snippet (code fragment) way. I experimented with it, and in St, code snippets were case sensitive. It's really not very convenient. I modified the next plugin, using the completion-file approach, which is case insensitive.
2. The original plug-in, the completion of the result is always "class name: Function name" form, I modified into a static function so output, the non-static function only output function name. For the example you gave, enter Ccdirector_sh, fill in Ccdirector:shareddirector (), then manually enter a colon, and then enter some full complement prompt (for example, Ccdgetvis), you can continue to complete the completion. You can also enter "Getvis" here, but because it is based on the text of the completion, may be complementary to other classes of methods, this does not know there is no better way.
3. This plugin is primarily a Python script build.py, put it with the tools/tolua++ directory in the COCOS2DX directory, and then run the script to generate the latest version of the API.
I modify this plugin is mainly modified build.py this script and some templates, you need the above features, you can go to this address to download
Https://github.com/wtyqm/cocos2dx-lua-tools re:chinesetree2013 2013-07-21 22:58 [Reply] reply wtyqm: The landlord good, according to the landlord method, Now the function of calling the complement function across files is normal.
About
1. Fill ignores case
2. More intelligent complementary full COCOS2DX API
Get the latest API when 3.COCOS2DX API engine updates
These 3 functional solutions can be understood as only need to use the landlord after the modified bulid.py and pkg file regeneration. And then replace the resulting
Sublime Text 2/packages/cocos2d The files in the LUA API directory. RE:WTYQM 2013-07-22 05:50 [Reply] reply u011446040: Yes.  From Https://github.com/wtyqm/cocos2dx-lua-tools, copy build.py, three template files, copy the latest pkg files from cocos2dx, regenerate them, and then copy them to the St directory. Re: chinesetree2013 2013-07-22 18:12 published [Reply] reply wtyqm: Landlord to give you feedback a small bug and suggestion.
According to the method provided by the landlord, in the snippets folder will be generated
Api.sublime-completions and enum.sublime-completions These 2 files use these 2 to make up, but at the end of the generated file, there is a comma, which leads to the loss of complement function, at first I manually delete the 2 comma, after the restart St, found still not, see Once again, the original bulid.py caused the 2 commas to appear again. Later is to remove this build.py to normal completion, but can be filled or very strong.
Another minor problem is that I'm using the Mac system. The Python version is 2.7.2 causing some of the parameters in the script to be unrecognized, and upgrading from Python is cumbersome and easily causing other problems.

I use the way is: the landlord to provide the build.py,template_completions_item.sublime-completions,template_completions.sublime-completions, Template.sublime-snippet put into the St inside, and then put the newest tolua++ also together into St inside. Then run the Python script.

In general, the landlord is still very good to the force. Thank you very much, it is about the feedback to you these small problems, if the landlord has time also by the way optimization off. It would be much better to use it. Look forward to the landlord's reply. RE:WTYQM 2013-07-22 22:15 [Reply] reply u011446040: The comma you say is the comma behind the last table entry in the Api.sublime-completions file.
I look like this here:
{"Trigger": "X", "Contents": "X"},
]
}
But on my system (Mac OS X, ST2\ST3), it can be fully filled.
I use the method is, in the non-St directory to generate complementary files, only to copy the full file into the St directory. If the build.py also copy the past, it is likely to cause each start of the St to regenerate the completion of the full file, do not know if there is any possibility of causing errors.
My Mac system also recently installed python3.3, download the installation package directly from the Python website. After installation 2.7.2 and 3.3 can coexist. The default Python command is version 2.72. The terminal window input python3.3 is version 3.3. It is also very convenient to upgrade.
You can follow the way I said above (complement the entire file external generation, installation python3.3) Try, if there is a comma problem, you are welcome to send me the completion of the document, further determine the issue re:chinesetree2013 2013-07-23 22:43 published [Reply] Reply WTYQM: According to the landlord prompted the installation of the python3.3.2 is very good, will not be the conflict with the system, 2 versions coexist. The scripts are running smoothly under the python3.3.
Before checking some online, many people say that some systems rely on their own python, upgrade fear caused some unnecessary trouble. Now it looks like it's not a problem, huh?

Commas refer to the last line in the Enum.sublime-completions and api.sublime-completions files.
There's a comma like this ","
"Kcctextalignmentright",
]
}
If the comma is not removed this seems to be a malformed format, look up St about completions format is like this. This address http://sublimetext.info/docs/en/extensibility/completions.html
I'm using ST2. I don't know why I have a comma here. Not a normal complement. And the landlord's but can. I only have to manually remove the comma to complete the success.
In addition, I do not know how to send the file .... RE:WTYQM 2013-07-28 23:03 [Reply] reply u011446040: Sorry for a long time to reply. The last comma question, though not knowing the exact reason, but I have modified the build.py, removed the comma, welcomed the trial. In addition to the actual use of any problems and improvements, you can communicate at any time.
I am in the actual use, feel API complement, fault tolerance is too strong, will hinder this document has entered the word completion speed, some uncomfortable. re:chinesetree2013 2013-08-02 09:35 [Reply] reply wtyqm: Um. These days are also relatively slow, just free. See the landlord back to fix the problem. Go ahead and try.
It's a bit unpleasant, but normal development, these functions are enough. 1/F lihei12345 2013-07-18 12:26 [Reply] [quote] [report] Like the landlord, I was fork before, the results were deleted, and now generally are direct star.
In addition, the boss can be tolua++ the principle of more detailed points, coupled with code analysis and so on. I recently contacted Cocos2d-x, also want to use LUA, but because of the lack of understanding of the principle and just contact game development, dare not use, want to understand the binding principle of tolua++ to start using, and lack of skill ... Very tangled, ask eldest brother help write analysis process, kneeling Xie re:wtyqm 2013-07-18 21:36 [Reply] [quote] [report] reply lihei12345: Look at the star feature you introduced, it seems to be used to focus on interested projects good.
tolua++ binding principle, you are recommended to read the next http://dualface.github.io/blog/2012/08/25/tolua-plus-plus-implement/
Actually, look at it. Programming in Lua, the binding principle of tolua++ is easy to understand after the chapters on exporting C functions to Lua. COCOS2DX's LUA binding is also more mature, time tight words can first try to use, side by side to deepen understanding re:lihei12345 2013-07-19 00:10 Published [reply] [quote] [report] reply WTYQM: The landlord is really good. You must continue to pay attention to your blog, refueling.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.