Game Development Reference
In-Depth Information
What just happened?
You created a scene transition animation with Cocos2d-x.
As I mentioned earlier, this form of scene change will cause a new instance of the new lay-
er to be created each time, and destroyed each time it's replaced by a new scene. So, in our
game,
MenuLayer
and
LevelSelectLayer
are instantiated and destroyed as many
times as the user switches between them.
There is also the option to use
pushScene
instead of
replaceScene
. This creates a
stack of
scene
objects and keeps them all in memory. This stack can be navigated with
popScene
and
popToRootScene
.
Now let me show you how to do the same thing but with a singleton layer.
It should be no surprise to you by now that you will find many examples of these transition
classes in the
Tests
, project at
tests/cpp-tests/Classes/TransitionsTest
.