What to do when game is in paused state?

What to do when game is in paused state?

Switch to the Paused state upon appropriate user input. Paused. Upon entering this state, apply a visual effect to the game screen to indicate that gameplay is paused. Remove the effect when exiting the state. (There is no need to suspend gameplay operation during this state, as game logic is invoked only during the Playing state.)

Which is an example of a state machine?

State machines can be applied to any part of your game that involves state-dependent behavior. The following examples walk through designs of several different state machines. Consider a 2D “endless running” game—in this style of game, the player character runs automatically, and the player must press a jump button to pass obstacles.

When to call enterstate on a state machine?

When your game logic requires a change in state, call the state machine’s enterState: method to choose a new state. The Maze sample code project (already seen in the Entities and Components chapter) implements a variation on several classic arcade games.

How is a state machine defined in GameplayKit?

In GameplayKit, a state machine is an instance of the GKStateMachine class. For each state, you define the actions that occur while in that state, or when transitioning into or out of that state, by creating a custom subclass of GKState. At any one time, a state machine has exactly one current state.

How to change the state of the game?

Switch to the Playing state upon user input. Playing. While in this state, call per-frame update logic for gameplay. Switch to the Paused state upon appropriate user input. Paused. Upon entering this state, apply a visual effect to the game screen to indicate that gameplay is paused. Remove the effect when exiting the state.

How is the state of the game related to gameplay?

In nearly all games, gameplay-related logic is highly dependent on the current state of the game. For example, animation code might change depending on whether a player character is currently walking, jumping, or standing.