iPhone Game Development

Errata for iPhone Game Development

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page chapter 3
various pages

There are several places where the authors state ..."(don't forget to add the appropriate header functions)". Wouldn't it be better to simply show that part of the code as well. Some readers may not understand [exactly] what to do? Why not show all of the code?

lawrence Fletcher  Jan 05, 2010 
PDF Page 3
3rd paragraph

Spotlight is not able to find the file on my computer. I have the latest sdk installed (3.1.2)

debug42  Jan 14, 2010 
Printed Page 8
after step 8

I have a suggestion for this title -readers may become very frustrated without this procedure: Page 8 (Chapter 1): Add the step 8.5: Rebuild the project. Without this correction, the instructions of step 9 will not be possible and frustrating for the reader.

Anonymous  Apr 02, 2010 
Printed Page 14

Step #2 not required in latest versions of Xcode. You can select XIB created when .h and .m for TestViewController created in step 1.

Anonymous  Nov 29, 2009 
Printed Page 15
Point 5

// Code: IBOutlet TestViewController* testViewController; // --> Results in Build error: "expected specifier-qualifier-list before ..." // This code works: IBOutlet UIViewController *testViewController;

Anonymous  Dec 30, 2009 
Printed Page 39
Code in middle of page, under "void main_loop()"

The function stateHandleEventFPTR() in the book is missing the "m_" prefix, and should be written m_stateHandleEventFPTR().

Steven Fullmer  Oct 14, 2010 
Printed Page 70, 74
Read before posting error for pages 71-...

If anyone is have problems with the implementation section starting on page 71 Most of the issues have been addressed and resolved (loosely speaking). Especially, read Nicks post regarding these issues. Thanks Nick. Regarding Pg. 74 bottom code: IPHONE_WIDTH, IPHONE_HEIGHT.. add these definitions To: yourSample_AppDelegate #define IPHONE_WIDTH 320 #define IPHONE_HEIGHT 480 [where "yourSample" is the name you are using for your applications main AppDelegate, in this section it is Test_FrameworkAppDelegate.h Arrrrrh! I hope the authors rewrite the code for the book examples and provide a pdf.

lawrence Fletcher  Dec 31, 2009 
Printed Page 71-77

My mistake, I had thought the code on these pages was the same as the Example project but after finding the code crashes as soon as I try to run it in the simulator, I have taken a closer look. The Example project has no gsTest files, it has no mainLoop function in the appDelegate, and doesn't use the Render function, but drawRect instead. When the ActiveSDK is changed to 3.1.2 it does run in the simulator, which is more than the code in the book does. There is no project called Test_Framework in the files downloaded from SourceForge, the project is called Chapter3_Framework. However, that project has no gsMain files or gsTest files either. When the active SDK is changed to 3.1.2 the code does compile, but with warnings. It still uses stringWithContentsOfFile in the Resource Manager DirectoryMasher function - this was deprecated with the release of version 3.0 (in June I believe). In short, the code in the book between pages 71-77, does not seem to resemble any of the example projects downloaded from Sourceforge, whose code is out of date anyway. It has many small errors, and doesn't work, even when these are corrected. The gsMain view displays for a fraction of a second and then the app crashes.

Nick Glasier  Nov 29, 2009 
Printed Page 71-77

Thanks for writing the book, so far so good. The theory is very helpful for me, and it seemed well written as a primer. I'm confused about the implementation that starts on pg. 71. Is the code in the book correct? Or, should we reference the downloadable code at, for the correct code, while using the book for the explanation of the process? Also step 1. you did not name the project but you reference it in step 5. (convoluted). step 2. you can select the class type of subclass in the New File dialogue box, so there's no need to change it in the header file in step 4 (GameState.h UIView). Thanks

Lawrence Fletcher  Dec 30, 2009 
Printed Page 72
code segment at bottom of page

//gsMain.h @interface gsTest: GameState { should be @interface gsMain: GameState {

Nick Glasier  Nov 28, 2009 
Printed Page 72
Code segment at bottom of page

NSLog(@"gsTest init"); should read NSLog(@"gsMain init");

Nick Glasier  Nov 28, 2009 
Printed Page 72
method Render

The code in the Render method returns errors, telling me that the context in not correct. <Error>: CGContextSetFillColorWithColor: invalid context and many more In general the code on these pages does not seem to be the same as the example project.

Robbert van Ginkel  Dec 07, 2009 
Printed Page 72
last code block // gsMain.h

I apologize in advance for this post because I am a beginner iPhone Developer, and as the book states, it's for intermediate developers. But maybe the authors will sympathizes with me anyway. gsMain. class... the code doesn't work for me. @interface gsTest : GameState { ....does not match the class title, Should it be: @interface gsMain : GameState { ? Also, this is not in the downloadable sample. This section of the book seems poorly organized. Even if this book where for advanced developers... the examples should have correct continuity. The voice of this "Framework" section seems too casual, like a lecture, not a textbook. I prefer a textbook approach for the coding section. I don't want to feel like I may need to find a "work-around" solution. This presentation feels like more like your saying ..."Hey, try this it might work". With regards to the book, aside from the coding examples, I feel it's a good effort and a lot of valuable information. But we readers get frustrated because we cannot tell whether the book is right for us coding wise. We brought the book, to LEARN coding. The code should just work. in my opinion...

lawrence Fletcher  Dec 30, 2009 
Printed Page 72
first paragraph

The drawRect function definition should read like this: -(void) drawRect:(CGRect)rect { [self Render]; // This line is not in the book version. } In the paragraph that follows this definition, it is mentioned that the drawRect function is rerouted to the Render function, but it's up to the reader to figure out just what that means (and easy to miss on a first pass). Without this change the test program will just display a black screen.

Anonymous  Jan 23, 2010 
Printed Page 72

The 10th line from the bottom of page 72 should read: @interface gsMain : GameState { and in the 1st line from the bottom of the page change gsTest to gsMain. There should be no mention of gsTest at this point.

Thomas Sinclair  Aug 27, 2010 
Printed Page 73

Hi my name is Lawrence, If anyone wants to discuss the book, or work together to try and resolve some of the problems posted here, you may email me. Visual Development iPhone Beginner Developer

lawrence Fletcher  Dec 30, 2009 
Printed Page 73
top of page -(void) render code

I typed following code, it doesn't work for me. the program compiles, displays a black screen, and kick out ... CGContext invalid errors to the console. -(void) render { CGContextRef g = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(g, [UIColor grayColor].CGColor); CGContextFillRect(g, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)); CGContextSetFillColorWithColor(g,[UIColor blackColor].CGColor); [@"O'Reilly Rules!" drawAtPoint:CGPointMake(10.0, 20.0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]]; } When I replace the code with the following, it prints to console just fine. { NSLog(@"print this"); }

lawrence Fletcher  Dec 31, 2009 
Printed Page 73
Method - (void) Render

The method - (void)Render, gsMain.m class, cannot be implemented like showed in the book. The correct implementation is like in the downloaded project (method drawRect in the same class needs modifications too): - (void)render { [self setNeedsDisplay]; } - (void) drawRect:(CGRect) rect { CGContextRef g = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(g, [UIColor grayColor].CGColor); CGContextFillRect(g, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)); CGContextSetFillColorWithColor(g, [UIColor blackColor].CGColor); [@"O'Reilly Rules!" drawAtPoint:CGPointMake(10.0, 20.0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]]; } In the same way, FPS code test in page 76 wont works too. So, again you need to change the method drawRect and include the code that is supposed to be in method Update: - (void) drawRect:(CGRect) rect { // Old code omitted. int FPS = [((GameFrameworkAppDelegate*)m_pManager)getFramesPerSecond]; NSString* strFPS = [NSString stringWithFormat:@"%d", FPS]; [strFPS drawAtPoint:CGPointMake(10.0, 60.0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]]; }

Reinaldo de Oliveira Castro  Jan 26, 2010 
Printed Page 73
Source Code for gsMain.m

I wasn't able to successfully run the app after reaching page 73. I tried iOS 4.0 and 3.2 on the simulator and an iPod Touch. The following fixed it for me. In gsMain.m move the code in Render to drawRect and update Render as follows: -(void) Render { [self setNeedsDisplay]; //this sets up a deferred call to drawRect. } - (void)drawRect:(CGRect)rect { CGContextRef graphicsContext = UIGraphicsGetCurrentContext(); // fill background with gray. CGContextSetFillColorWithColor(graphicsContext, [UIColor grayColor].CGColor); CGContextFillRect(graphicsContext, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)); // draw text in black. CGContextSetFillColorWithColor(graphicsContext, [UIColor blackColor].CGColor); [@"O'Reilly Rules!" drawAtPoint:CGPointMake(10.0, 20.0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]]; }

Thomas Sinclair  Aug 27, 2010 
Printed Page 74
Code segment at bottom of page

Either the constants IPHONE_WIDTH and IPHONE_HEIGHT have not been defined anywhere, or the reader has not been told to define them.

Nick Glasier  Nov 29, 2009 
Printed Page 74
README.rtf that accompanies sample code for this chapter

The README.rtf file that accompanies the sample code (errata for page 74) has IPHONE_WIDTH and IPHONE_HEIGHT reversed. It should read: pg74 - add #import "gsMain.h" to *AppDelegate.m, In your Example_prefix.pch file add: "#define IPHONE_WIDTH 320" "#define IPHONE_HEIGHT 480" Note: the PCH file is where you put definitions that should be available to all of your source code

Mike Grayson  Feb 24, 2010 
Printed Page 76
code segment halfway down the page.

Adding code to the Update function, the first line refers to Test_FrameworkAppDelegate. When the project is first created no project name is suggested; however, the code so far resembles the Example project downloaded from Sourceforge far more than the Chapter3Framework project. Furthermore, in the text on page 71, at the beginning of the section on Implementation, instruction 5. refers to ExampleViewController.m which is a part of the Example project, but on Page 74 at the top of the page, it is the Test_FrameworkAppDelegate class which is referred to in both the text and the sample code below. Some clarification would be helpful, especially for beginners in iPhone programming.

Nick Glasier  Nov 29, 2009 
Printed Page 79
Management section

Once you get to this section it all starts to come right, and a great deal easier to follow. The book is now dealing with the same code as the Chapter3 Framework project, although it never actually names it, which is a pity as there are two projects in the download for Chapter 3..

Nick Glasier  Nov 29, 2009 
PDF Page 84
5th line from the end of page

greyColor should be grayColor

Note from the Author or Editor:
Unable to find the problem. The following is a copy of the last 7 lines of page 84: It is very easy to use this class: //Initialize the font for use in a constructor GLFont* tex = [ GLFont alloc]; [ tex initWithString:@" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.!?, " fontName: @"Helvetica" fontSize:15.0f]; //Draw a string to the screen in a Render function [ tex drawString: @"I love monkeys!" atPoint:CGPointMake(20, 300)];

Ron Bingham  Nov 07, 2009 
Printed Page 85
Item number 5

None in the book or in the project there is a #import statement to function glClearColor(0xff/256.0f, 0x66/256.0f, 0x00/256.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); works. The line bellow must be included. #import <OpenGLES/ES1/gl.h> Serious guys, do you ever test the project in this book?

Reinaldo de Oliveira Castro  Jan 26, 2010 
Printed Page 86
The code

I'm trying this on Simulator 4.2 or my iPhone 4. It's not working. There is only an orange background. The downloaded sample code does not work either. Does this have anything to do with my old book vs new xCode/SDK/device or maybe the opengles 1 is old or anything? I get layer <CAEAGLLayer: 0x4be8370> in NSLog. No errors, but no textures (png or font) either.

Anonymous  Mar 15, 2011 
Printed Page 95

When building the Chapter 3 project, you get the following (minor) error in the ResourceManager.m Minor Error on this line: NSString* loaded = [NSString stringWithContentsOfFile:filePath]; XCode warns that 'stringWithContentsOfFile' is deprecated! Although the code runs anyway. ------- Also a separate issue, but a strange behaviour - I added the FPS again on the final project at the end of Chapter 3. I found that the font works in the Simulator, but not in iPhone device! It happens if you modified the code in ResourceManager.m as hinted on P84 to include numbers for the FPS. Here is the line I edited: default_font = [[GLFont alloc] initWithString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.?!@/: " Now on the iPhone device all a get is white boxes where the letters/numbers should appear - but on the simulator all works fine. Very Strange. Anyone any light on this?

David Douglas  Jan 11, 2010 
Other Digital Version 344
rd paragraph

It seems the sample code will not compile with iOS 4.2 Errors (there are several) are: Setting a C++ non-POD object value is not implemented... It would be nice to see an update to the source to fix this. In the mean time, can you suggest a code change or compiler setting workaround?

Anonymous  Jan 20, 2011