Game Development Reference
In-Depth Information
_playerNode = center;
_softBodyPlayer = YES;
}
CGPoint offset = (_softBodyPlayer ?
_playerNode.parent.positionInPoints
: CGPointZero);
[self scrollToTarget:_playerNode withOffset:offset];
}
If the
_playerNode
has children, which is only the case for the new soft-body player
object, the first object replaces the
_playerNode
reference. This makes the soft-body
player's center node the new
_playerNode
. The
_softBodyPlayer
ivar is set to
YES
to indicate that this level is using the soft-body player.
version is already being called. The new version takes an
offset
parameter to account
for the fact that the center node's position is an offset to its parent position rather than be-
ing in-scene coordinates.
Locate the
update:
method in
GameScene.m
. It also needs to be updated with the
changes highlighted in
Listing 10-6
.
Listing 10-6
.
Accelerating all bodies and scrolling with offset
-(void) update:(CCTime)delta
{
if (_acceleratePlayer)
{
if (_softBodyPlayer)
{
for (CCNode* node in
_playerNode.parent.children)
{
[self accelerateTarget:node];
}
}
else
{
[self accelerateTarget:_playerNode];
Search WWH ::
Custom Search