Game Development Reference
In-Depth Information
9. Now, let's go to
FSMyScene.m
, remove the default code added in the
init
method and also the method for touch detection.
10. Make a property for a
SKSpriteNode
called spaceship in the private interface:
@interface FSMyScene()
@property (nonatomic, strong) SKSpriteNode*
spaceShipSprite;
@end
11. Add this
spaceShipSprite
to the
FSMyScene
file in its
init
method:
self.spaceShipSprite = [SKSpriteNode
spriteNodeWithImageNamed:@"Spaceship"];
self.spaceShipSprite.position =
CGPointMake(self.spaceShipSprite.size.width,
size.height/2);
[self addChild:self.spaceShipSprite];
The default
Spaceship.png
provided is appropriate, so delete and add
Spaceship.png
provided in the
Resources
folder of the Starter kit.
12. Now if you run the app, the spaceship doesn't look good on a black background,
so give the sky color background color to
FSMyScene
file in its
init
method.
self.backgroundColor = [UIColor colorWithRed:135.0/
255.0 green:206.0/255.0 blue:235.0/255.0 alpha:1.0];
So finally we have reached the goal and have placed a spaceship in the sky.
The final
FSMyScene
class looks like this: