The Penguin class
The Penguin
class publicly inherits from CCSprite
and it is similar in terms of structure to the GameObject
class you saw in the previous chapter. It possesses a b2Body
object along with functions that update its position based on its body. The body of the penguin will have a circle-shaped fixture applied to it. We will skip all of that boilerplate code and discuss the behavior of the penguin.
Penguin behavior |
Description |
---|---|
Awake |
The penguin will be asleep at the start of the game. The player will have to touch the screen to wake him up. |
Diving |
This is true as long as the player is tapping the screen. A downward force is constantly applied to the penguin so long as he is diving. |
Flying |
This is true when the penguin is airborne and false when he is sliding on the surface of the hill. |
Perfect slide |
When the penguin launches off a slope above a certain velocity, it's a perfect slide. |
Fever |
The penguin enters into a trance like fever when he does three perfect slides... |