April 2021
Beginner to intermediate
506 pages
11h 57m
English
In GameplayKit, you use the GKStateMachine superclass to create state machines. A state machine holds the list of possible states, the current state, and some logic for moving between the states.
For Val’s Revenge, you’ll create a player state machine that controls the player’s state, specifically for tracking when players have a key versus when they don’t.
In the Project Navigator, switch to the Player.swift file. Below the line that reads import SpriteKit, add the following new import statement to import the GameplayKit framework:
| | import GameplayKit |
Next, you need a property to hold the state machine for the Player class. Add the following code at the top of the Player class, just above the currentDirection ...
Read now
Unlock full access