mirror of https://github.com/axmolengine/axmol.git
Fix: error C2360: initialization of 't' is skipped by 'case' label (#1146)
* Fix: error C2360: initialization of 't' is skipped by 'case' label case ExampleGameState::update: ///////////////////////////// // Add your codes below...like.... // // UpdateJoyStick(); // UpdatePlayer(); // UpdatePhysics(); // ... int t = 10; break; * Update HelloWorldScene.cpp * Update HelloWorldScene.cpp
This commit is contained in:
parent
872693b5e0
commit
973239f8a0
|
@ -47,9 +47,9 @@ bool HelloWorld::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
auto visibleSize = _director->getVisibleSize();
|
auto visibleSize = _director->getVisibleSize();
|
||||||
auto origin = _director->getVisibleOrigin();
|
auto origin = _director->getVisibleOrigin();
|
||||||
auto safeArea = _director->getSafeAreaRect();
|
auto safeArea = _director->getSafeAreaRect();
|
||||||
auto safeOrigin = safeArea.origin;
|
auto safeOrigin = safeArea.origin;
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||||
|
@ -57,7 +57,7 @@ bool HelloWorld::init()
|
||||||
|
|
||||||
// add a "close" icon to exit the progress. it's an autorelease object
|
// add a "close" icon to exit the progress. it's an autorelease object
|
||||||
auto closeItem = MenuItemImage::create("CloseNormal.png", "CloseSelected.png",
|
auto closeItem = MenuItemImage::create("CloseNormal.png", "CloseSelected.png",
|
||||||
AX_CALLBACK_1(HelloWorld::menuCloseCallback, this));
|
AX_CALLBACK_1(HelloWorld::menuCloseCallback, this));
|
||||||
|
|
||||||
if (closeItem == nullptr || closeItem->getContentSize().width <= 0 || closeItem->getContentSize().height <= 0)
|
if (closeItem == nullptr || closeItem->getContentSize().width <= 0 || closeItem->getContentSize().height <= 0)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ bool HelloWorld::init()
|
||||||
// 3. add your codes below...
|
// 3. add your codes below...
|
||||||
|
|
||||||
// Some templates (uncomment what you need)
|
// Some templates (uncomment what you need)
|
||||||
auto touchListener = EventListenerTouchAllAtOnce::create();
|
auto touchListener = EventListenerTouchAllAtOnce::create();
|
||||||
touchListener->onTouchesBegan = AX_CALLBACK_2(HelloWorld::onTouchesBegan, this);
|
touchListener->onTouchesBegan = AX_CALLBACK_2(HelloWorld::onTouchesBegan, this);
|
||||||
touchListener->onTouchesMoved = AX_CALLBACK_2(HelloWorld::onTouchesMoved, this);
|
touchListener->onTouchesMoved = AX_CALLBACK_2(HelloWorld::onTouchesMoved, this);
|
||||||
touchListener->onTouchesEnded = AX_CALLBACK_2(HelloWorld::onTouchesEnded, this);
|
touchListener->onTouchesEnded = AX_CALLBACK_2(HelloWorld::onTouchesEnded, this);
|
||||||
|
@ -134,7 +134,7 @@ bool HelloWorld::init()
|
||||||
drawNode->setPosition(Vec2(0, 0));
|
drawNode->setPosition(Vec2(0, 0));
|
||||||
addChild(drawNode);
|
addChild(drawNode);
|
||||||
|
|
||||||
drawNode->drawRect(safeArea.origin + Vec2(1,1), safeArea.origin + safeArea.size, Color4F::BLUE);
|
drawNode->drawRect(safeArea.origin + Vec2(1, 1), safeArea.origin + safeArea.size, Color4F::BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scheduleUpdate() is required to ensure update(float) is called on every loop
|
// scheduleUpdate() is required to ensure update(float) is called on every loop
|
||||||
|
@ -207,10 +207,13 @@ void HelloWorld::update(float delta)
|
||||||
switch (_gameState)
|
switch (_gameState)
|
||||||
{
|
{
|
||||||
case ExampleGameState::init:
|
case ExampleGameState::init:
|
||||||
|
{
|
||||||
_gameState = ExampleGameState::update;
|
_gameState = ExampleGameState::update;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ExampleGameState::update:
|
case ExampleGameState::update:
|
||||||
|
{
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Add your codes below...like....
|
// Add your codes below...like....
|
||||||
//
|
//
|
||||||
|
@ -219,36 +222,44 @@ void HelloWorld::update(float delta)
|
||||||
// UpdatePhysics();
|
// UpdatePhysics();
|
||||||
// ...
|
// ...
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ExampleGameState::pause:
|
case ExampleGameState::pause:
|
||||||
|
{
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Add your codes below...like....
|
// Add your codes below...like....
|
||||||
//
|
//
|
||||||
// anyPauseStuff()
|
// anyPauseStuff()
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ExampleGameState::menu1:
|
case ExampleGameState::menu1:
|
||||||
/////////////////////////////
|
{ /////////////////////////////
|
||||||
// Add your codes below...like....
|
// Add your codes below...like....
|
||||||
//
|
//
|
||||||
// UpdateMenu1();
|
// UpdateMenu1();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ExampleGameState::menu2:
|
case ExampleGameState::menu2:
|
||||||
/////////////////////////////
|
{ /////////////////////////////
|
||||||
// Add your codes below...like....
|
// Add your codes below...like....
|
||||||
//
|
//
|
||||||
// UpdateMenu2();
|
// UpdateMenu2();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ExampleGameState::end:
|
case ExampleGameState::end:
|
||||||
/////////////////////////////
|
{ /////////////////////////////
|
||||||
// Add your codes below...like....
|
// Add your codes below...like....
|
||||||
//
|
//
|
||||||
// CleanUpMyCrap();
|
// CleanUpMyCrap();
|
||||||
menuCloseCallback(this);
|
menuCloseCallback(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} //switch
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloWorld::menuCloseCallback(Ref* sender)
|
void HelloWorld::menuCloseCallback(Ref* sender)
|
||||||
|
@ -260,6 +271,6 @@ void HelloWorld::menuCloseCallback(Ref* sender)
|
||||||
* _director->end() as given above,instead trigger a custom event created in RootViewController.mm
|
* _director->end() as given above,instead trigger a custom event created in RootViewController.mm
|
||||||
* as below*/
|
* as below*/
|
||||||
|
|
||||||
// EventCustom customEndEvent("game_scene_close_event");
|
// EventCustom customEndEvent("game_scene_close_event");
|
||||||
//_eventDispatcher->dispatchEvent(&customEndEvent);
|
//_eventDispatcher->dispatchEvent(&customEndEvent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue