Game Development Reference
In-Depth Information
Figure 3-19 . The game's node hierarchy in its current state
Tip You can dump the entire node hierarchy in its current state to the console
by writing [self walkSceneGraph:0] anywhere in your code. This can be useful
if you suspect a node may not be in the correct location in the node hierarchy.
Also note that scene graph can be used synonymously with node hierarchy .
Before you get the background layers to scroll again, let's recap the code from the
scrollToTarget: method. Listing 3-12 includes the change made in Listing 3-11 .
Listing 3-12 . Version of scrollToTarget: that assigns position to _physicsNode
-(void) scrollToTarget:(CCNode*)target
{
CGSize viewSize = [CCDirector sharedDirector].viewSize;
CGPoint viewCenter = CGPointMake(viewSize.width / 2.0,
viewSize.height / 2.0);
CGPoint viewPos = ccpSub(target.positionInPoints,
viewCenter);
CGSize levelSize = _levelNode.contentSizeInPoints;
viewPos.x = MAX(0.0, MIN(viewPos.x, levelSize.width
- viewSize.width));
Search WWH ::




Custom Search