Game Development Reference
In-Depth Information
self—otherwise it won't be visible and it would appear as if the previous scene
just froze.
The update method then uses a simple switch statement based on the provided
TargetSceneTypes enum to determine which scene is to be replaced. The default
switch contains an NSAssert , which always triggers when the default case is hit.
This is good practice because you'll be editing and expanding this list several times,
and if you forgot to update the switch statement with a new case, you'll be notified
of that.
This is a very simple LoadingScene implementation that you can use in your own
games. Simply extend the enum and switch statement with more target scenes or use
the same target scene multiple times but with different transitions. But as I mentioned,
don't overdo the transitions just because they're cool-looking.
Using the LoadingScene has an important effect regarding memory. Because you're
replacing the existing scene with the lightweight LoadingScene and then replacing
the LoadingScene with the actual target scene, you're giving the previous scene
enough time to remove itself from memory. Effectively there's no longer any overlap
of two potentially memory-hungry scenes at the same time, thereby reducing spikes in
memory usage during scene changes.
Working with Multiple Layers
The project ScenesAndLayers02 illustrates how you can use multiple layers to scroll
the contents of a game's objects layer while the content of the user interface layer,
where it says “Here be your Game Scores” (see Figure 5-1 ) , remains static. You'll learn
how multiple layers can cooperate and react only to their own touch input, as well as
how to access the various layers from any node.
Search Nedrilad ::

Custom Search