Merge pull request #1006 from aismann/dev

Improve cpp-template
This commit is contained in:
一线灵|Deal 2023-01-03 06:21:20 +08:00 committed by GitHub
commit 94ec87a19c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 2 deletions

View File

@ -116,12 +116,64 @@ bool HelloWorld::init()
drawNode->drawRect(safeArea.origin, safeArea.origin + safeArea.size, Color4F::BLUE);
}
return true;
myGameState = myGameState::update;
scheduleUpdate();
return true;
}
void HelloWorld::update(float delta)
{
switch (myGameState)
{
case myGameState::update:
/////////////////////////////
// Add your codes below...like....
//
// UpdateJoyStick();
// UpdatePlayer();
// UpdatePhysics();
// ...
break;
case myGameState::pause:
/////////////////////////////
// Add your codes below...like....
//
// anyPauseStuff()
break;
case myGameState::menu1:
/////////////////////////////
// Add your codes below...like....
//
// UpdateMenu1();
break;
case myGameState::menu2:
/////////////////////////////
// Add your codes below...like....
//
// UpdateMenu2();
break;
case myGameState::end:
/////////////////////////////
// Add your codes below...like....
//
// CleanUpMyCrap();
_director->end();
break;
}
}
void HelloWorld::menuCloseCallback(Ref* sender)
{
// Close the cocos2d-x game scene and quit the application
// Close the axmol game scene and quit the application
_director->end();
/*To navigate back to native iOS screen(if present) without quitting the application ,do not use

View File

@ -28,13 +28,30 @@
#include "axmol.h"
enum myGameState
{
update = 0,
pause,
end,
menu1,
menu2,
menu3,
};
class HelloWorld : public ax::Scene
{
public:
virtual bool init() override;
void update(float delta);
// a selector callback
void menuCloseCallback(Ref* sender);
private:
myGameState myGameState;
};
#endif // __HELLOWORLD_SCENE_H__