Contents

GKState

The abstract superclass for defining state-specific logic as part of a state machine.

Declaration

class GKState

Overview

The GKState abstract class defines the features of state classes to be used with a state machine (a GKStateMachine object). You build a state machine by defining a separate GKState subclass for each state of the machine. In each state class, you use the isValidNextState(_:) method to define which other states are valid for a machine to transition into. State classes provide a place to put state-dependent game logic, such as actions that should happen when entering or exiting a specific state, or per-frame update code that is valid only when in a specific state.

For more information about state machines, read State Machines in GameplayKit Programming Guide.

Topics

Creating a State

Working with State Machines

Handling State Transitions and Updates

See Also

State Machines