It is time to write some game code – fantastic! Open your GameScene.swift
file and find the didMoveToView
function. Recall that this function fires every time the game switches to this scene. We will use this function to get familiar with the SKSpriteNode
class. You will use SKSpriteNode
extensively in your game, whenever you want to add a new 2D graphic entity.
Note
The term sprite refers to a 2D graphic or animation that moves around the screen independently from the background. Over time, the term has developed to refer to any game object on the screen in a 2D game. We will create and draw your first sprite in this chapter: a happy little bee.
Let's begin by drawing a blue square to the screen. The SKSpriteNode
class can draw both texture graphics and solid blocks of color. It is often helpful to prototype your new game ideas with blocks of color before you spend time with artwork. To draw the blue square, add an instance of SKSpriteNode...