As we mentioned earlier in the chapter, the sprite kit is focused around creating sprite nodes. For each item in a sprite kit game, a node will be created for the type. Let's start with our background. In order to create a background image node, we will first need to create a SKSpriteNode
, assign it to a variable, and tell it which image to use. A sprite node is considered to be a textured node but can be initialized with a texture, a named image as we are doing here, or just as a colored square. The code for sprite node creation is as follows:
SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"background"];
There are currently seven different types of node classes associated with the SKNode
class that each have their own set of properties, which are as follows:
SKSpriteNode
: This class is for textured sprites for imagesSKVideoNode
: This class is for playing digital videoSKLabelNode
: This class is a text nodeSKShapeNode
: This class...