Game Development Reference
In-Depth Information
{
[self showPopoverNamed:@"UserInterface/Popovers/
GameOverMenuLayer"];
return YES;
}
The third parameter is named
saw
, in line with the
Collision type
of each saw pre-
fab. If there is a collision between player and saw, the method simply shows the
GameOverMenuLayer
popover now. It's a pretty harsh ending, but alas, there will
not
be blood. Not now, anyway.
Note
If you find that some or all of the saws do not run the collision method in
Listing 6-17
, open each saw prefab in the
Prefabs
folder in SpriteBuilder. Each
of them should have their
Collision type
set to
saw
on the
Item Physics
tab. You
may want to confirm this now, and where the
Collision
type is missing or incor-
rect, enter
saw
. Be sure to check the sprite node of each CCB, not their root
nodes.
Interlude: Fixing the Initial Scroll Position
Wow! Game Over was quick. Is there anything else we could do?
You may have noticed that when you press the restart button or whenever you change
from the menu scene to the game scene, the level view isn't centered on the player ini-
tially. That's kind of bad, and it's a result of the GameScene updating its scroll position
only after the first time the
update:
method has run. But the very first frame is rendered
earlier.
Fortunately, the fix is easy. Open
GameScene.m
, and locate the
loadLevelNamed:
method. Add the highlighted line of
Listing 6-18
at the end of the method.
Listing 6-18
.
Fixing the initial scroll position
-(void) loadLevelNamed:(NSString*)levelCCB
{
// existing code omitted ...
[self scrollToTarget:_playerNode];
}
Search WWH ::
Custom Search