Game Development Reference
In-Depth Information
Note
Changing the color property applies the so-called
color-tinting
effect to
the node. You cannot make a sprite brighter than its original image through tint-
ing because there is no brighter tint color than white. Applying white as the col-
or (the default) will make the node look like its original image.
Since unlocking levels occurs only while playing the
GameScene
, the code in
Listing 8-8
does not need to re-run every time the
Scroll View
is shown. This is good because the
Scroll View
simply toggles its visible state to show and hide; therefore,
didLoadFromCCB
will run only once, when the
MainScene
has been loaded.
Closing the Level-Selection Popover
The level-selection popover can be closed with the
CloseButton.ccb
instances
you've already added to each page. The
CloseButton
class forwards the
shouldClose
message to the first parent that implements it. So that's what you'll have
to do, meaning that you add the code in
Listing 8-9
just below the
didLoadFromCCB
method in
MainMenuLevelSelect.m
.
Listing 8-9
.
Closing means hiding the Scroll View
-(void) shouldClose
{
self.parent.visible = NO;
[_mainMenuButtons show];
}
The
Content
node's parent instance is the
Scroll View
. So all it takes is to set the parent's
visible status to
NO
and then let the
MainMenuButtons
node show itself.
Loading Levels
What's left is to register button presses for each level and test if that level is unlocked or
not. If it is, load the level; otherwise, well, maybe later you'll play a dismissive sound ef-
fect in that case.
Search WWH ::
Custom Search