Drawing Scenes and Sprite Nodes

The template is a fine starting point, but if you’re going to send the spaceship on a daring rescue mission, you need to figure out how to draw it yourself and understand what’s going on. In this section, we’re going to write code to experiment with scene setup and then talk about what goes on behind the curtain.

Start by deleting the contents in the RCWMyScene.m file that came with the template. Replace it with this implementation of the RCWMyScene class that displays the spaceship image in the middle of the screen:

01-SpriteIntro/step01/SpaceRun/RCWMyScene.m
 
#import ​"RCWMyScene.h"
 
 
@implementation​ RCWMyScene
 
 
- (id)initWithSize:(CGSize)size
 
{
 
if​ (self = [super initWithSize:size]) {
 
self.backgroundColor ...

Get Build iOS Games with Sprite Kit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.