Game Development Reference
In-Depth Information
Tip Always consider the “Keep it simple stupid,” or KISS, principle (not to be
mistaken for the band of the same name). See ht-
tp://en.wikipedia.org/wiki/KISS_principle . The principle
translates to this: If you can create the same behavior with less code, choose to
write less code . Less code has fewer bugs and is easier to understand, change,
and reuse. Watch out specifically for duplicated code or code that does essen-
tially the same thing except for a few parameters. This is code that ought to be
extracted into its own method.
This setup suffices to try out the Scroll View in Xcode. Publish, build, and run. You can
now swipe the three background images left and right, and each page will snap to the area
defined by the Scroll View . Notice also how you can still tap the buttons underneath the
Scroll View . You can also test the boundaries where the Scroll View still accepts touch and
drag movements and where it doesn't.
Designing the Scroll View Content Node
What you can't do at this point is actually tap a level to play it, nor can you close the
Scroll View popover. To be able to do that, let's finalize the design of the level-selection
pages so that each page represents a given world.
Note I'll use the # character as a placeholder for the digits 1, 2, and 3 whenever
I want to refer to the entire group of W#_something images in the following de-
scriptions.
Start by adding a close button to each page. Open MainMenuLevelSelect.ccb . Then drag
and drop one CloseButton.ccb onto each W#_bg sprite. Do so by using either the Tileless
Editor View with the correct UserInterface folder at the bottom checked, or by dragging
the CloseButton.ccb from the File View . It's best to drop each button directly onto a
W#_bg sprite so that it becomes a child of the page background image.
Select each CloseButton , and change its Position types to % and its values to 100 on the
Item Properties tab. That's all that the buttons need.
Search WWH ::




Custom Search