Game Development Reference
In-Depth Information
One last thing, remember how you used the _levelNode in the
touchBegan:withEvent: method to convert the touch location relative to the
_levelNode ? You'll have to replace this use of _levelNode with _physicsNode
as well, as seen in the code fragment in Listing 3-15 .
Listing 3-15 . Replace _levelNode with _physicsNode in touchBegan:withEvent
CGPoint pos = [touch locationInNode:_physicsNode];
If you were to keep using the _levelNode , you would notice that you're prevented
from scrolling further than approximately half a screen size. That's because the
_levelNode no longer changes its position during scrolling, with the _physicsNode
having taken its place.
Publish, build, and run. You can now see the background layers parallaxing like in Figure
3-20 .
Figure 3-20 . Player moving toward the right and up shows the effect of parallaxing background layers
Summary
In this chapter, you learned how to control the player with touches and actions, and how to
scroll the level contents and background layers as the player moves about the level. You
also learned a lot about images, SpriteSheets and the settings related to image conversion
and publishing.
Search WWH ::




Custom Search