O'Reilly logo

Sparrow iOS Game Framework Beginner's Guide by Johannes Stein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating an asset container class

To put all of our asset managers into one single class, use the following steps:

  1. Add a new Objective-C class called Assets derived from NSObject within the Assets group.
  2. Define a static method for each kind of asset, as shown in the following code:
    +(SPTexture *) texture:(NSString *)filename;
    +(SPSound *) sound:(NSString *)filename;
    +(NSString *) plainText:(NSString *)filename;
    +(NSDictionary *) dictionaryFromJSON:(NSString *)filename;
  3. In the Asset.m file, import all asset managers, as shown in the following code:
    #import "TextureManager.h"
    #import "SoundManager.h"
    #import "FileManager.h"
  4. For each manager, add a static variable with the appropriate type and set its values to nil:
    static TextureManager ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required