Game Development Reference
In-Depth Information
Figure 13.2 A seam is visible between scrolling layers in an earlier version of
Ship Attack .
In any event, Ship Attack uses two layers scrolling at different speeds in order to
create a parallax effect (as covered in Chapter 2 ). The star field scrolls much more
quickly than the nebula, thus giving the perception that the star field is closer than
the nebula.
Ship
One thing you might notice about this game's code is there isn't a class that's
called“GameObject.”Instead,thecodeuses CCSprite (acocos2dclassthatrep-
resents a sprite object) as the base class for objects in the game. So for the case of
the player's ship, the Ship class inherits directly from CCSprite , as opposed to
any other intermediary class.
The init function for Ship sets up a looping animation for the Ship using ac-
tions , which comprise a cocos2d system for having a CCNode do something. For
example, there are actions to run an animation, move to a specific location, and
so on. These actions very much simplify certain behaviors because it's possible to
give a command and hand it off to cocos2d.
Search WWH ::




Custom Search