Game Development Reference
In-Depth Information
scene transition from FirstLayer to SecondLayer , based on the logging inform-
ation from the ScenesAndLayers01 project:
1. scene: SecondLayer
2. init: SecondLayer
3. onExitTransitionDidStart : FirstLayer
4. onEnter: SecondLayer
5. // Transition is running here for a few seconds
6. onExit: FirstLayer
7. onEnterTransitionDidFinish: SecondLayer
8. dealloc: FirstLayer
At first, SecondLayer 's + (id) scene method is called to initialize a CCScene .
This also adds a CCLayer to the scene. The SecondLayer 's init method is then
called, directly followed by the onEnter method in line 4. Just before that, all the
nodes in FirstLayer receive the onExitTransitionDidStart message as a
hint that the scene has started to transition to another scene.
In line 5, the transition is animating the new scene, and when it's done, the
FirstLayer and all its nodes receive the onExit message before the FirstLay-
er is deallocated in line 8. At the same time the SecondLayer receives the onEn-
terTransitionDidFinish message in line 7.
If you're not using a scene transition to change scenes, the process changes slightly.
Most notably the FirstLayer and its nodes receive the onExit message right
away, and are also deallocated immediately following onExit . The SecondLayer
and its nodes receive both onEnter and onEnterTransitionDidFinish mes-
sages consecutively, making them interchangeable. Receiving the onEnterTrans-
itionDidFinish method in this case is superfluous; I would consider this a bug
and wouldn't rely on that behavior to stay.
The following is the sequence of messages sent to FirstLayer and SecondLayer
in the order they will occur during the scene change without using a transition:
Search Nedrilad ::

Custom Search