O'Reilly logo

iOS 7 Game Development by Dmitry Volevodz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Character states

In order to correctly handle states, we will expand our character code to handle different states that can occur. Firstly, we need to identify the states, which are as follows:

  • Running state: This is the default state when the character is running on the ground
  • Jumping state: This is the state when we press a button to jump, but it should be limited so that we don't continue the jumping state when we are in the air
  • In air state: This is the state when the character is still in the air following a jump

In order to use these states, let's define them in ERGPlayer.h:

typedef enum playerState {
    
    playerStateRunning = 0,
    playerStateJumping,
    playerStateInAir
    
} playerState;

This code creates a new type of variable that is internally a usual ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required