Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Time for action – managing remaining file types


To create an asset manager for our files, use the following steps:

  1. Add a new Objective-C class called FileManager, which is derived from AssetsDictionary within the Assets group.

  2. Define an instance method called registerPlainText, as shown in the following code:

    -(NSString *) registerPlainText:(NSString *)filename;
  3. Define another instance method called registerDictionaryFromJSON, as shown in the following code:

    -(NSDictionary *) registerDictionaryFromJSON:(NSString *)filename;
  4. Implement the registerPlainText method with the following content:

    if ([_dict valueForKey:filename] == nil) {
      NSString *path = [[NSBundle mainBundle] pathForResource:filename];
      NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
      
      return (NSString *) [self registerAsset:filename withContent:content];
    } else {
      return (NSString *) [self registerAsset:filename withContent:nil];
    }
  5. Implement the registerDictionaryFromJSON...