Game Development Reference
In-Depth Information
Note If GameScene still contains a button that changes scenes, you should re-
move it, because it is no longer needed.
You should now publish, build, and run the app. Tap play, and load the first level. This
should present the GameScene with the first level. This proves that the level was loaded
correctly; if it hadn't been, the GameScene would have been a black screen with just the
pause button on it.
Winning Levels
What happens if you play through the level and reach the exit? That's right, the view re-
sets to the lower left corner and you're stuck. It's time to fix that and unlock the next level
at that point.
In SpriteBuilder, right-click the UserInterface/Popovers folder to add a New File . Name
the document LevelCompleteLayer.ccb , and set its type to Layer before creating it. Then
change the root node's content size types to % and values to 100x100. Then switch to the
Item Code Connections tab, and enter GameMenuLayer as the class name. That's your
collective popover class shared by the other in-game popover layers.
You need a background image, label, and button. From the UserInterface section in the
Tileless Editor View , drag any image that ends in _bg onto the stage. For instance, I used
W2_bg . Change the background sprite's position types to % and its values to 50x50 and
you're done with it.
Then switch to the Node Library View , and drag a Label TTF node onto the background
sprite so that the label becomes a child of the sprite. Change the label's position types to
% and its values to 50x66. Set the label's Title to something that indicates level complete-
ness—for instance, “Level Complete” sounds fine. Feel free to change the label in any
way you like.
Last, add a Button from the Node Library View and drop this onto the background sprite,
also making it a child. Change the button's position types to % and its values to 50x30. A
preferred size of 170x50 enlarges the button image slightly. The button's Title should read
Next Level or something similar. Also, change the SpriteFrame of both Normal State and
Highlighted State to SpriteSheets/UserInterface/P_resume.png , and change both Back-
ground and Label color of Highlighted State to a light gray ( #999999 ) for visual feedback
when the button is pressed.
Search WWH ::




Custom Search