Game Development Reference
In-Depth Information
self.visible = YES;
[self scheduleUpdate];
-(void) update:(ccTime)delta
self.position = ccpAdd(self.position, velocity);
if (self.position.x > outsideScreen)
self.visible = NO;
[self unscheduleUpdate];
Sprite Animations the Hard Way
Now brace yourself. I'd like to show you how sprite animations work. Figure 6-3
shows the ship's animation frames. Remember that you have the entire animation in
both HD and SD resolution.
Figure 6-3 . The ship's animation—five frames with different flames
Sprite animations are another good reason to use CCSpriteBatchNode , because
you can put all animation frames into the same texture to conserve memory. It's quite a
bit of code actually, as you'll see in Listing 6-11 and in the Sprites01 project. After
that, I show you how to create the same animation using a texture atlas, which cuts
down the amount of code you have to write.
Listing 6-11. Adding an Animation to the Ship Without Using a Texture Atlas Requires
Quite a Bit of Code
// Load the ship's animation frames as textures and create a sprite frame
NSMutableArray* frames = [NSMutableArray arrayWithCapacity:5];
Search Nedrilad ::

Custom Search