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:
These are the base classes from which each major application state will inherit.
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
NSUserDefaultsto 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 ...