1

I've been programming with Cocos2d for a while now and I'm pretty familiar with it. But when it comes down to Cocos2d-x lua script, I'm having a really hard time understanding and following the structures. The Cocos2d-x lua template comes with a sample script "hello.lua", which is good, I follow through it and understand it no problem. However, bellowing are my questions,

1, In Cocos2d, you can struct a custom CCSprite class and import"SpriteClass.h" in another class that needs it. And in Cocos2d-x lua, you can create the same custom sprite script and access it in another script via require "scriptname", yeah? So, all you need to write is script and no need to create any classes?

2, I want to learn how to bind C++ the lua in Cocos2d-x lua. I posted this question here and got a pretty good answer, but after reading and searching, I still have trouble figure out where is the binding take place. Should I write it in a .ccp class or .lua script? I also trying to find any samples to study from but I found no luck. Can anyone here post any good source to learn or any sample code I can study?

PS: this question isn't the same as the other one I posted. I'm asking how to separate script so that I don't write everything in one script. As well as some example binding codes I can study.

4

0 回答 0