Game Development Reference
In-Depth Information
that's about it. The user interface is probably minimal, noninteractive, and purely in-
formative without any interactive elements other than a pause button.
I imagine this approach works best for twitch-based action game levels.
Layers as Levels
Using separate layers in the same scene to load and display levels is an approach I re-
commend if you have a complex user interface that should not be reset when a level
changes. You may even want to keep the player and other game objects in the exact
same positions and states when changing levels.
You probably have a number of variables that keep the current game state and user in-
terface settings, such as an inventory. It's more work to save and restore these game set-
tings and reset all visual elements than to switch out one layer with another within the
same scene.
This may be the ideal solution for a hidden object or adventure game, where you move
from room to room, especially if you want to replace the level contents using an anima-
tion that moves in or out beneath the user interface.
The CCLayerMultiplex class may be the ideal solution for such an approach. It
can contain multiple nodes, but only one is active at any given time. Listing 5-10
shows an example of using the CCLayerMultiplex class. The only drawback is
that you can't transition between the layers. There's only one layer visible at a time,
which makes any transition effects impossible.
Listing 5-10. Using the CCMultiplexLayer Class to Switch Between Multiple Layers
CCLayer* layer1 = [CCLayer node];
CCLayer* layer2 = [CCLayer node];
CCLayerMultiplex* mpLayer = [CCLayerMultiplex layerWithLayers:layer1, layer2, nil];
// Switches to layer2 but keeps layer1 as child of mpLayer.
[mpLayer switchTo:1];
// Switches to layer1, removes layer2 from mpLayer and releases its memory.
 
 
Search Nedrilad ::




Custom Search