Game Development Reference
In-Depth Information
_playerNode = [_physicsNode getChildByName:@"player"
recursively:YES];
}
cause it's being used to search for the player, so it must be assigned by that point. The ver-
_backgroundNode
because they should always be direct children of the
_levelNode
.
Now in the
scrollToTarget:
method, you need to locate the last line:
_levelNode.positionInPoints = ccpNeg(viewPos);
Replace it with the line in
Listing 3-11
in order to reroute the position updates from the
_levelNode
to the
_physicsNode
.
Listing 3-11
.
Replace _levelNode with _physicsNode in scrollToTarget
_physicsNode.positionInPoints = ccpNeg(viewPos);
This will decouple the
_backgroundNode
position so that it can be updated independ-
ently from the
_physicsNode
position, whereas the
_levelNode
position will now
remain fixed at 0,0. If you publish, build, and run now, you will notice that the back-
ground layers stay fixed.
To visualize the current layout, look at
Figure 3-19
. This is the node hierarchy as returned
by a call to
[CCBReader loadAsScene:@"GameScene"]
. In brackets are the
CCB files where the content of certain nodes originates from. Note that GameScene, des-
pite its name, is a regular
CCNode
subclass and not a subclass of
CCScene
.
Search WWH ::
Custom Search