add new class to lua( using tolua++)


#1

If i want to use a class in Lua which declare in my cocos2d-x project, must I add the convert function to LuaCocos2d.cpp?
I wonder if I just do this: using myClass.h to write the myClass.pkg, using tolua++ convert myClass.pkg to .cpp.
After I’ve done this, if I add the content of the
.cpp to LuaCocos2d.cpp, I can use the class of myClass.h in the .lua files correctly.
Now, my problem is I don’t want to add the .cpp to LuaCocos2d.cpp, I want to add the.cpp to my project and let the *.cpp and the LuaCocos2d.cpp work together.
Would anyone tell me what should i do.
Thanks a lot !


#2

Added class CCKeyboardNotificationLayer these are the files I had to change or add and some of the changes.

file: cocos2dx\Android.mk (for cygwin build)
text_input_node/CCKeyboardNotificationLayer.cpp
file: cocos2dx\include\cocos2d.h
#include “text_input_node/CCKeyboardNotificationLayer.h”

file: cocos2dx\proj.win32\cocos2d.vcproj done by Visual Studio

added file: cocos2dx\text_input_node\CCKeyboardNotificationLayer.cpp
added file: cocos2dx\text_input_node\CCKeyboardNotificationLayer.h
new class

file: scripting\lua\cocos2dx_support\LuaCocos2d.cpp (generated by tolua*+ and ant)
file: tools\tolua**.lua
“CCKeyboardNotificationLayer”,
added file: tools\tolua**.pkg
class related info
file: tools\tolua*+2d.pkg (for tolua++)
$pfile “CCKeyboardNotificationLayer.pkg”

Good luck
Andre


#3

Hello, you can see my article below:
http://star199111.blog.163.com/blog/static/188789311201342634383/
hope can offer you some help.:slight_smile: