GVBox Production wrote:
and if i pause update this scene how can i create button to resume it ?
when the game is in pause state, you can show a Layer with inside a button resume and update only this layer.
>
This button must be addChild in another scene ? like HUD ?
>
And how can i create HUD for my scene ?
>
This is my first project in cocos2d-x and C++ so i have many question .
ok!
Now I write a pause system that work for me and not for cocos2d-x in classic mode:
there is few layer…
class MySpritesLayer : public frw::res::manager {
…to draw the sprite games
};
…
there is a resume button…
class MyResumeButton : public frw::res::button {
…pressed resume game
void onPresed() { frw::message::manager::getInstance()->sendMessage(“GAME”, kMessageGameResume);
};
there is a pause menu
class MyPause : public frw::res::menuPopup {
inside create the resume button
MyPause() {
*resumeButton = new MyResumeButton;
push;
}
…destroy etc…
};
there is a scene:
class MyScene : public frw::core::scene, public frw::message::listener, {
virtual void initialize {
…create layers
*pause = false;
*layerSprites = new MySpritesLayer;
*layerPause = new MyPause();
*layerPause~~>hide; // hide the pause in first time
push;
push;
}
virtual void finalize {
… destroy everything
}
virtual void update {
if {
*layerPause->update; // update layer pause and button resume
return;
}
…
*layerSprites~~>update; // update sprites
}
virtual void onMessage {
switch {
// when arrived the resume message
case kMessageGameResume: {
*pause = false;
*layerPause~~>hide;
break;
}
// when arrived the pause message
case kMessageGamePause: {
*pause = true;
*layerPause~~>show;
break;
}
}
}
bool*pause;
};
however, I don’t use cocos2d-x in the classic mode, I have generate the framework because I want have the control for my layer updates (I am old school of game programming :))
So, I am not the correct person to explain cocos2dx in the classic mode
Regards!