Game Development Reference
In-Depth Information
Here scene is what the method returns. To access the MainScene 's root node, you
would have to write
CCNode* rootNode = scene.children.firstObject;
Now that you have an instance of a CCScene , it can be presented with an optional trans-
ition:
CCTransition* transition = [CCTransition
transitionFadeWithDuration:1.5];
[[CCDirector sharedDirector] presentScene:scene
withTransition:transition];
A transition is a way to animate the scene change. The fade transition fades one scene to
black before fading the new scene in. You can also use cross-fade, fading to color and a
variety of moving and pushing transitions.
What are these transition methods' exact names? This information is always at your fin-
gertips with Xcode code completion suggestions—if you don't get suggestions, check that
the option is turned on under Xcode Preferences
Text Editing
Suggest completions
while typing.
Once you start typing parts of a class or method name, you should see a list of the avail-
able completion suggestions like in Figure 2-12 . If not, try pressing the ESC key at this
point.
Figure 2-12 . Taking advantage of Xcode auto-completion suggestions
Tip You can also find a list of transitions in the Cocos2d class reference:
http://www.cocos2d-swift.org/docs/api/Classes/
CCTransition.html . Or type CCTransition anywhere in Xcode, and then
right-click the text and select Jump to Definition. (Alternatively, put the cursor
anywhere on the text and select Navigate Jump to Definition from the
menu.) This will open the interface for CCTransition , where you'll find,
Search WWH ::




Custom Search