Chapter 3. The Framework

In this chapter, we’ll start creating a game application by building up the application framework. This will contain code necessary to get your application started, by initializing subsystems and starting the main loop. It will also form a layer between the iPhone OS and your game, providing resource management and abstracting complicated APIs such as graphics and sound. In essence, the framework should take care of as many common tasks as possible, so developers on new projects can immediately begin to implement game-specific code with as little work as necessary.

For our example game, the framework will consist of the following components:

The GameState and GameStateManager classes

These are the base classes from which each major application state will inherit.

The AppDelegate class

This is where the application begins and ends.

Event handling

This will be handled separately by each game state class.

The Resource Manager

We will create a singleton to provide resource loading and management, as well as functionality including textures, sounds, and user data.

The render engine

This uses OpenGL ES to render textures in 2D format. Later we can expand on this to allow 3D graphics as well.

The sound engine

This uses OpenAL and Audio Queue to play music and sound effects.

The data store

This uses NSUserDefaults to store and load user preferences and game progression data in persistent memory.

Finally, in this chapter, we will create a skeleton project to show off the framework ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.