September 2014
Beginner
266 pages
5h 38m
English
Now, we implement the pause and resume buttons in HelloWorldScene:
We will add the gamePaused() and gameResumed() functions in the HelloWorldScene class. For this, create two functions in the HelloWorldScene.h:
void gamePaused();
void gameResumed();Next, we define these functions in the HelloWorldScene.cpp file:
void HelloWorld::gamePaused()
{
this->unscheduleUpdate();
this->unschedule(schedule_selector(HelloWorld::spawnEnemy));
if(gameplayLayer->getEnemiesArray()->count() >0)
{
for(int i=0; i< gameplayLayer->getEnemiesArray()->count(); i++)
{
Enemy* en = (Enemy*) gameplayLayer->getEnemiesArray()->objectAtIndex(i);
en->pauseSchedulerAndActions();
}
}
}Once the game is paused, we unschedule the update and ...
Read now
Unlock full access