Game Development Reference
In-Depth Information
1. First of all, copy all the images (that is, frames) of the coin as provided in the
Project_Resources folder with the kit. There are total six images of coins,
each rotated at an angle horizontally.
2. Add a method to FSMyScene called addCoin in which we create a sprite for
the coin with the initial image to be displayed on the sky background using tex-
ture ( Coin1.png ).
SKTexture* coinInitialTexture = [SKTexture
textureWithImageNamed:@"Coin1.png"];
SKSpriteNode* coinSprite = [SKSpriteNode
spriteNodeWithTexture:coinInitialTexture];
3. To show the coin on the screen, specify its position; as of now, the position is set
to the center of the screen, and then add it to the FSMyScene .
coinSprite.position =
CGPointMake(self.frame.size.width/
2,self.frame.size.height/2);
[self addChild:coinSprite];
4. Similarly, create textures for the remaining frames of the coin to add frame anim-
ations.
SKTexture* coin2Texture = [SKTexture
textureWithImageNamed:@"Coin2.png"];
SKTexture* coin3Texture = [SKTexture
textureWithImageNamed:@"Coin3.png"];
SKTexture* coin4Texture = [SKTexture
textureWithImageNamed:@"Coin4.png"];
SKTexture* coin5Texture = [SKTexture
textureWithImageNamed:@"Coin5.png"];
SKTexture* coin6Texture = [SKTexture
textureWithImageNamed:@"Coin6.png"];
Combining all coin textures creates an array of texture.
NSArray *coinAnimationTextures =
@[coinInitialTexture,coin2Texture,coin3Texture,coin4Texture,coin5Texture,coin6Texture];
Search WWH ::




Custom Search