Game Development Reference
In-Depth Information
-((playerNode!.position.y - 180.0)/8));
backgroundStarsNode!.position
= CGPointMake(backgroundStarsNode!.position.x,
-((playerNode!.position.y - 180.0)/6))
self.foregroundNode!.position
= CGPointMake(self.foregroundNode!.position.x,
-(self.playerNode!.position.y - 180.0));
}
}
Notice the bolded section of the modified
update()
method. With these two lines I am
moving the stars relative to the
playerNode
, but I am moving them at a slightly slower
rate than the
backgroundNode
. This gives the illusion that the
back-
groundStarsNode
is closer to the viewport of the scene. Make this change to the
up-
date()
method and run the application again. When the game is first launched, you will
see a scene that looks like
Figure 5-4
.