while(!done)
{
update(); // keep the game content moving
}
The above code shows the very important mechanic in game development. Without the loop, the game will always static. But in Cocos2d-x framework, things have changed. I don't do this ugly looping anymore, I just need to override the
update(float) in the Scene object like this:
class HelloWorld : public cocos2d::Layer
{
public:
...
...
virtual bool init();
void update(float d);
};
void HelloWorld::update(float d)
{
...
...
}
And then activate it in the
init() like this:
bool HelloWorld::init()
{
...
this->scheduleUpdate();
return true;
}
No comments:
Post a Comment