Categories class development game iphone programming singleton WordPress

iPhone Game Programming – Tutorial 7 – Singleton Class

This is a small tutorial on how to create and use a Singleton class. Whilst I’ve been creating these tutorials it has become clear that managing state is important in your game. The ability to manage both the OpenGL state locally and also any state related to your game is a key building block for a game.

The Singleton pattern is a design pattern that is used to restrict the number of instantiations of a class to just one object. For our purposes we are going to use it to control state information we want to make global and share throughout our game, or at least available to other objects which want to get state information.

This tutorial covers the creation of a simple Singleton class and how it is implemented to provide state control of the currently bound OpenGL texture. I will be using this Singleton class in coming tutorials to help manage any state which is why I’ve done this tutorial to get the concept introduced.
Check out these cool WordPress plugins! – CodeRevolution.