user1817517
user1817517

Reputation: 349

Cocos2d-x lua binding

After some researches, i found that Cocos2d-x lua is binding on top of C++, which make sense to me, since Cocos2d-x is c++ version of Cocos2d. But when I saw this Wiki, it seems they have some sort of information about binding c++ and java to lua, but when I clicked the link it said to be determined. And this confuse me a little, why Cocos2d-x lua still need to bind C++ to it?

I looked into Luabind here, it stated that "It (Luabind) has the ability to expose functions and classes, written in C++, to Lua. It will also supply the functionality to define classes in lua and let them derive from other lua classes or C++ classes." And I still not quit getting it, what is binding and what does it do actually?

If you know any good source or good tutorial to teach how to bind C++ and java to Cocos2d-x lua, I would very appreciate you share here.

Thank you in advance for your time and answers

Upvotes: 3

Views: 3244

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

Cocos2d-X uses tolua(++) as its binding mechanism and not Luabind. The principle remains the same though. Both frameworks provide ways for the user to specify which classes/methods will be available in Lua, and how Lua should treat those objects.

This is called "binding" and typically involves generating wrapper code for methods and classes, which is cumbersome and error prone to maintain if you were to do this manually. Lua binding frameworks trade some speed and efficiency for ease of use and correctness.

If you want to learn tolua I suggest you start with the tolua documentation as well as looking at cocos2d-x examples for Lua bindings.

Upvotes: 3

Related Questions