Game Development Reference
In-Depth Information
Figure 5-2 . The utility of multiple layers becomes clear once the GameLayer is zoomed out and rotated, with all its
nodes adhering to the layer's behavior, while the UserInterfaceLayer on top remains in place, unaffected
How to Best Implement Levels
So far you've examined multiple scenes and multiple layers. Now you want to cover
what—levels?
Well, the concept of levels is common in many games, so I don't think I need to ex-
plain that. What's much harder is deciding which approach best serves a level-based
game. In cocos2d you can go either way—choosing a new scene for each level or using
separate layers to manage multiple levels. Both have their uses, and which one to
choose depends mostly on what purpose levels serve in your game.
Scenes as Levels
The most straightforward approach is to run each level as a separate scene. You can
either create a new Scene class for each level or choose to initialize one common
LevelScene class and pass as a parameter the level number or other information ne-
cessary to load the correct level data.
This approach works best if you have clearly separated levels and most everything that
happens within a level is no longer relevant or needed after the player has progressed
through that level. Maybe you keep the player's score and the number of lives left, but
 
Search Nedrilad ::




Custom Search