mirror of https://github.com/axmolengine/axmol.git
28 lines
1.6 KiB
Plaintext
28 lines
1.6 KiB
Plaintext
1. The usage of tolua++
|
|
You can use the command to generate the LuaCocos2d.cpp:
|
|
tolua++.exe -tCocos2d -o LuaCocos2d.cpp Cocos2d.pkg
|
|
|
|
2. Modify the generated file
|
|
After you run the command, the generated file under the
|
|
directory the same as tolua++.exe. cocos2dx/lua_support/LuaCocos2d.cpp
|
|
is generate by this way. But here are some differents between them, because
|
|
tolua++.exe generates some error codes about the template. The errors are:
|
|
|
|
-------------------------------------------------------------------------------------------
|
|
genereated code | correct code |
|
|
-------------------------------------------------------------------------------------------
|
|
CCMutableArray<cocos2d::CCSpriteFrame*> | cocos2d::CCMutableArray<CCSpriteFrame*> |
|
|
-------------------------------------------------------------------------------------------
|
|
CCMutableArray<cocos2d::CCFiniteTimeAction*> | cocos2d::CCMutableArray<CCFiniteTimeAction*>|
|
|
--------------------------------------------------------------------------------------------
|
|
CCMutableArray<cocos2d::CCObject*> | cocos2d::CCMutableArray<CCObject*> |
|
|
--------------------------------------------------------------------------------------------
|
|
|
|
3. The regular to write .pkg
|
|
1) enum keeps the same
|
|
2) remove CC_DLL for the class defines, pay attention to multi inherites
|
|
3) remove inline keyword for declaration and implementation
|
|
4) remove public protect and private
|
|
5) remove the decalration of class member variable
|
|
6) keep static keyword
|
|
7) remove memeber functions that declared as private or protected |