Fix cpp-template (#1016)

* Committing genbindings changes

* Fix compilation error related to redefinition of 'pause'
Fix update override warning
Improve code

* Revert "Fix compilation error related to redefinition of 'pause'"

This reverts commit 1744a48fec.

* Fix compilation error related to redefinition of 'pause'
Fix update override warning
Improve code
This commit is contained in:
RH 2023-01-06 16:02:55 +11:00 committed by GitHub
parent 857f669970
commit f59d786b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 26 deletions

View File

@ -116,8 +116,7 @@ bool HelloWorld::init()
drawNode->drawRect(safeArea.origin, safeArea.origin + safeArea.size, Color4F::BLUE);
}
myGameState = myGameState::update;
// scheduleUpdate() is required to ensure update(float) is called on every loop
scheduleUpdate();
return true;
@ -125,9 +124,13 @@ bool HelloWorld::init()
void HelloWorld::update(float delta)
{
switch (myGameState)
switch (_gameState)
{
case myGameState::update:
case ExampleGameState::init:
_gameState = ExampleGameState::update;
break;
case ExampleGameState::update:
/////////////////////////////
// Add your codes below...like....
//
@ -137,28 +140,28 @@ void HelloWorld::update(float delta)
// ...
break;
case myGameState::pause:
case ExampleGameState::pause:
/////////////////////////////
// Add your codes below...like....
//
// anyPauseStuff()
break;
case myGameState::menu1:
case ExampleGameState::menu1:
/////////////////////////////
// Add your codes below...like....
//
// UpdateMenu1();
break;
case myGameState::menu2:
case ExampleGameState::menu2:
/////////////////////////////
// Add your codes below...like....
//
// UpdateMenu2();
break;
case myGameState::end:
case ExampleGameState::end:
/////////////////////////////
// Add your codes below...like....
//
@ -168,9 +171,6 @@ void HelloWorld::update(float delta)
}
}
void HelloWorld::menuCloseCallback(Ref* sender)
{
// Close the axmol game scene and quit the application

View File

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