Game Development Reference
In-Depth Information
How to do it…
First of all, we will be replacing the creation of textures using the image by the texture atlas
images in App Bundle . Perform the following steps:
1. Create an object of SKTextureAtlas by specifying its name that is, FSGame
(name of the texture atlas).
SKTextureAtlas *textureAtlas = [SKTextureAtlas
atlasNamed:@"FSGame"];
Note
The images previously added to the project bundle should be removed to avoid re-
dundancy.
SKTexture* spaceShipTexture = [SKTexture
textureWithImageNamed:@"Spaceship.png"];
2. Now create the texture using a texture atlas object by passing the spaceship image
that has to be set to the sprite.
SKTexture* spaceShipTexture = [textureAtlas
textureNamed:@"Spaceship.png"];
3. In the addCoin method of FSMyScene, use the preceding process to create the
textures using the t extureAtlas object for all coin textures.
SKTextureAtlas *textureAtlas = [SKTextureAtlas
atlasNamed:@"FSGame"];
SKTexture* coinInitialTexture = [textureAtlas
textureNamed:@"Coin1.png"];
SKTexture* coin2Texture = [textureAtlas
textureNamed:@"Coin2.png"];
SKTexture* coin3Texture = [textureAtlas
textureNamed:@"Coin3.png"];
SKTexture* coin4Texture = [textureAtlas
textureNamed:@"Coin4.png"];
Search WWH ::




Custom Search