Winning, losing, and other states

Shooting birds infinitely will get you bored at some point. You have to be able to win or lose the game to make it interesting. Also, our hunter shoots the arrows too fast. We should fix these issues before we can call our game minimally playable.

A good way to fix all of our issues is by introducing states. It is very common in game development to think about game objects or even the whole game itself as state machines.

To use states, you need to think upfront what states can your object be in and write the code to transition from one state to another. Then, you can check the current state of the object and understand what it can or should do in its current state. It will get clearer when we do this for our game ...

Get Learning iPhone Game Development with Cocos2D 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.