Game Development Reference
In-Depth Information
Initializing the game
Now back to GameLayer.cpp . If you take a look inside our init method, you will see
that the game initializes by calling three methods: createGameScreen , cre-
atePools , and createActions .
We'll create all our screen elements inside the first method, and then create object pools so
we don't instantiate any sprite inside the main loop; and we'll create all the main actions
used in our game inside the createActions method.
And as soon as the game initializes, we start playing the background music, with its
should loop parameter set to true :
SimpleAudioEngine::getInstance()-
>playBackgroundMusic("background.mp3", true);
We once again store the screen size for future reference, and we'll use a _running
Boolean for game states.
If you run the game now, you should only see the background image:
Search WWH ::




Custom Search