By Developers, For Developers

Historical errata for Build iOS Games with Sprite Kit

PDF PgPaper PgTypeDescriptionFixed onComments
19TYPO

“which means that it is should be rendered” -> “which means that it is rendered”

2014-03-17
11TYPO

The Road Ahead - Chapter 3 - “Through all this, we’ll learn quite about the built-in particle editor.” is missing something between ‘quite’ and ‘about’. Maybe ‘quite alot about’…

2014-03-17
2917ERROR

The code listing on page number 17 (page 29 in the PDF) refers to a method
- moveShipTowardPoint:byTimeDelta:

This is the first time we’ve seen that method. Previously, the method used was
-(void)moveShipByDelta:(NSTimeInterval)timeDelta

This is clearly an oversight, because you don’t go on to discuss this new method.

2014-03-17
29TYPO

Typo/grammatical error:
Existing text:
“Here’s an image demonstrating of the curve we want the ship to follow:”
Suggested change:
“Here’s an image illustrating the curve we want the ship to follow:”

2014-03-17
4836TYPO

“Collect more power-ups, and the timer to keeps resetting to give you more time.” —> typo under the heading “Implementing Weapon Power-ups with Actions” in chapter 2

2014-03-17
5543TYPO

In chapter 3, listing 03-Particles/step01/SpaceRun/RCWStarField.m, we have this line midway down:

star.alpha = 0.1 + arc4random_uniform(10) / 10.0f - 0.1;

Is there a reason that we add 0.1 and then subtract it back out?

2014-03-17Nope. :) Fixing it.
2512ERROR

In the code for 01-SpriteIntro/step05/SpaceRun/RCWMyScene.m:
1) The parameters to atan2() are reversed; they are supposed to be (y, x), not (x, y)
2) xOffset should be based on cos(angle)
3) yOffset should be based on sin(angle)

Thus, instead of:

CGFloat angle = atan2(dest.x - ship.position.x,
dest.y - ship.position.y);
CGFloat yOffset = distanceToTravel * cos(angle);
CGFloat xOffset = distanceToTravel * sin(angle);

it should be:

CGFloat angle = atan2(dest.y - ship.position.y,
dest.x - ship.position.x);
CGFloat yOffset = distanceToTravel * sin(angle);
CGFloat xOffset = distanceToTravel * cos(angle);

2014-03-17
9TYPO

“Obstacles - We want simple asteroids that just float aimlessly along a straight light,” should be “…along a straight line”

2014-03-17
3220ERROR

+removeFromParent and +sequence are class methods on SKAction, and should be designated by a “+” instead of a “-”. The sentence “We create the -removeFromParent action and then build a sequence by passing an array of all the actions to run in order to the -sequence: method on SKAction.” should be: “We create the +removeFromParent action and then build a sequence by passing an array of all the actions to run in order to the +sequence: method on SKAction.”

2014-03-17
6149TYPO

When we manipulate what we see in the Xcode particle editor, we’re actually manipulating the real properties on this of node.

—> “on this of node”, presumably intending “on this kind of node” or something

2014-03-17
6250TYPO

In code samples “03-Particles/step02/SpaceRun/SKEmitterNode+RCWExtensions.m”

We make a NSString with the extension, and then we don’t use it and just use @“sks” instead.

2014-03-17I updated the text on why I added this in. Since Apple's class methods allow leaving off the extension if you want, so should we.
3523ERROR

The methods +rotateByAngle:duration: and +repeatActionForever: are class methods, so should be designated with a “+” instead of “-” in the text. The sentences “The -rotateByAngle:duration: action rotates the node by the given number of radians one time. Because we want the asteroids to keep spinning, we wrap it in the -repeatActionForever: action so it will continue as long as the node is in the scene.” should be: “The +rotateByAngle:duration: action rotates the node by the given number of radians one time. Because we want the asteroids to keep spinning, we wrap it in the +repeatActionForever: action so it will continue as long as the node is in the scene.”

2014-03-17
3523ERROR

The +group method is a class method on SKAction and should be designated with a “+” instead of a “-”. The sentence: “That’s where the -group: action comes into play.” should be: “That’s where the +group: action comes into play.”

2014-03-17
36ERROR

In - (void)checkCollisions, self.shipTouch = nil does not stop the firing from (0,0) because the next touch creates a new shipTouch in - (void) touchesBegan. I added a BOOL property - shootingOK, initialized to true in init and set to false in checkCollisions. In -(void)shoot, the test becomes:

if (self.shipTouch && self.shootingOK)

2014-03-30Thanks for pointing this out, Stephen! In later chapters, this is addressed. And the game even restarts once you tap the screen again after exploding. I'll mark this fixed.
66TYPO

missing [ (bottom of page)

self.obstacleExplodeTemplate = [SKEmitterNode rcw_nodeWithFile:@“obstacleExplode.sks”];

2014-03-30Thanks! We'll make sure this is fixed when laying out the code.
32ERROR

The included enemypath.pcvd fails to open in my copy of PaintCode (1.3.4). It says the file is corrupt.

2014-03-30Thanks for catching this. It was an issue in the book build process that didn't copy this file as a binary. I'm having the publishing team fix this.
39ERROR

Should ‘[ship removeActionForKey…]’ be executed before setting self.shipFireRate to 0.1? Otherwise I think there is a race condition.

2014-03-30Good thinking! But in this case it doesn't matter. Everything about Sprite Kit happens on the main thread in sequence. There's no concurrency race condition danger here. If the ship is removed before setting ship fire rate to 0.1 then nothing will happen on the next frame render. The ship will just be gone.
104TYPO

- (void) addPoints:(NSInteger)score should read -(void) addPoints: (NSInteger)points

2014-03-30Great catch. Fixed!
113TYPO

- (void)showPowerupTimer:(NSTimeInterval)timer should read
- (void)showPowerupTimer:(NSTimeInterval)time

2014-03-30
12-13SUGGEST

A method that doesn’t incite as much of a trigonometric “yikes” if you’re concerned about that is available (and could work very nicely in your Figure 7 description:

int xDelta = point.x - ship.position.x;
int yDelta = point.y - ship.position.y;
CGFloat distanceLeft = sqrt(yDelta*yDelta+xDelta*xDelta);
if (distanceLeft > 4) {
CGFloat percentDelta = (timeDelta * shipSpeed) / distanceLeft;
ship.position = CGPointMake(ship.position.x + percentDelta * xDelta,
ship.position.y + percentDelta * yDelta);
}

2014-04-11Nice! Although, I think it's best to leave the trig shock in there. If nothing else to expose the readers to it and help them realize that they'll need to brush up on their math in general for many classes of problems. Besides, atan2() is just a plain useful function that many we've found don't know about. We're love to write a math book at some point. :)
61SUGGEST

I don’t particularly care for the notion of just copying in Main.storyboard when building along. This works fine for resource files like images or sounds, but I think that steps that modify the function of the project should be part of the tutorial. In particular, I’d rather take a page or two to follow along through the changes made than leave the book to do the same on my own.

2014-04-11I originally wrote out how to alter the storyboard, but it bogged down the chapter too much. I had 15 different figures trying to describe what to do. After deliberation with the publishers, we felt it best to recommend the reader check out Daniel's Storyboards book if they want to know more. This isn't a book about Storyboards.
62SUGGEST

(This occurs throughout the book) This isn’t a major issue, but a convention issue that you might want to think about. The convention in the book seems to be something like “Create a new file .h with [contents]… Create a file named .m with [contents]”. Usually in ObjC tutorial work, particularly when Xcode is assumed, I’m more often used to seeing something like “Create a new subclass of [BaseClass] named [MyPrefixBaseClass]” or similar.
I generally find this more readable and reflective of concept than file structure.

2014-04-11Thanks! I've been directed by the publisher to refer to the actual files to create because it is easier for people to also find the files in the sample code if they want to root around. I'm going to leave it as is.
91ERROR

"at the end of the initWithSize: method" I’m definitely being a touch pedantic here, but I think it works better to use code extracts with context and new material highlights to do this. It’s also not, strictly speaking, correct that you would want to place this code at the end of the method (after the super init check and return)

2014-04-11Ah, I see. Reworded that sentence.
95TYPO

elapsedValue.text = "0s"; should be elapsedValue.text = “0.0s”;
for consistency with later interface updates.

2014-04-11Thanks! Fixed!
104TYPO

- (void)showPowerupTimer:(NSTimeInterval)timer;

“timer” should become time to reflect function implementation on PDF page 105/106

2014-04-11Thanks! This was already addressed in #76557 and has been fixed in Beta 3.
106ERROR

The text refers to the need to use weakSelf for this block (bottom para), but the code is not consistent with this.

2014-04-11Egads! Thanks for catching this. I also found one other place in the chapter where I forgot to use weakSelf. Fixed!
60SUGGEST

‘by holding down the ^ key while dragging’ - Unclear what key this is (shift+6?). I chose right click and drag.

2014-04-14It's the control key. The publisher will add intro part of the book to explain keyboard shortcut symbols according to the Prag style.
33SUGGEST

When adding sound files to Xcode project, the add to targets radio button in Xcode does not select the SpaceRun project like it does for images. Not an error with the book, but this did send me off on a wild goose chase for 10 minutes. Would be a nice tooltip info box.

2014-04-14I do mention to make sure the game target checkbox is checked, but I'll update that to be more explicit. Thanks!
38SUGGEST

When adding the code to check if the ship has bumped into the powerup, the arrows on the left are missing from the code to indicate that new code is being added like in all other examples.

2014-04-14Fixed!
54SUGGEST

When specifying the thrust files for the explosions, missing the arrows on the left indicating new code.

2014-04-14Because both these lines are the only two that are added, I'm instructed to not add the highlight arrows. Those are only to indicate lines that have changed out of a bunch of lines.
52SUGGEST

When adding rcw_dieOutInDuration, did not instruct user to add method to header file resulting in compilation error.

2014-04-14Thanks for the catch! Added the instructions.
58SUGGEST

‘…you’ll want to copy the Main.storyboard file from the 04-Menus/step01/SpaceRun directory’

Main.storyboard is in the 04-Menus/step01/SpaceRun/Base.lproj directory.

2014-04-14Thanks! Fixed.
62SUGGEST

On page 8, the user was instructed to create RCWViewController with the viewDidLoad method. Inside the method has this line:
SKScene * scene = [RCWMyScene sceneWithSize:skView.bounds.size];

Then on page 62, the user is asked to add the endGameCallback. When adding there is a compilation error. Modifying the above mentioned line to
RCWMyScene * scene = [RCWMyScene sceneWithSize:skView.bounds.size];
resolves the error. This does match the source code linked which is why I marked it as a suggestion and not a technical error, but the user is not aware of the change.

Additionally there are spaces before the pointer on page 8 and not on 62.

2014-04-14Yeah, that's because Apple's template creates the view controller originally that way. The step to change the variable type to RCWMyScene got lost. I'll add that back in.
66SUGGEST

Missing new code arrows on easyMode thingprobability.

2014-04-14Awesome. Fixed!
141SUGGEST

I question the link to the blog on this page. Would be safer to point to the Apple Developer documentation.

  • Edit: I tried to put the link but the submit errata functionality blocks it for spam which seems overkill as there is a recaptcha.
2014-04-20Good point. Linking to Apple's docs instead.
170SUGGEST

Chapter 8 starts with step2 in the code base, does not mention step1 anywhere. Should there be a step1?

2014-04-20Step 1 is the starting point without any code changes for the chapter. The first code snippet refers to step 2 because that is where the file I'm referencing is changed.
173SUGGEST

Missing use of arrows to indicate new code to an existing block on RCWPullHintNode.m. Additionally, the entire code block is shown a couple of times, wherein the previous code block the top few lines were omitted on the second instance of it.

I’m not sure if I am being too anal or not, but thought I should err on the side of caution and point it out.

2014-04-20Great catch! My mistake when referencing the code. Fixed!
180SUGGEST

Bitmask was described and the wikipedia link was referenced in chapter 7 already on page 166.

In previous examples were something was touched on multiple times, a link to previous part in the book was linked.

2014-04-20Ah, good point. Fixed!
196SUGGEST

Kind of late in the game, but it is common in technical books for appendixes on how to do something some what related. I think a good appendix chapter or two could be on creating audio and graphics. You touch on it a bit in chapter9 but nothing too detailed.

2014-04-20Alas, I've reached the page count limits that I have no control over. We're mulling over writing another book, though. Especially on math.
63ERROR

When building the app from scratch and following along, in RCWViewController.m the SpriteKit template sets up:

SKScene * scene = [RCWMyScene sceneWithSize:skView.bounds.size];

The text does set the class for “scene” as “RCWMyScene” but that may not be obvious to a novice reader/coder. Shouldn’t be an indication that the class needs to be changed?

2014-04-29Thanks! Addressed in #76645.
12SUGGEST

Trig not required. See /photostream/#A2GfnH8tGErhQy at icloud.com for handwritten notes.

2014-04-29Thanks Jim! Errata #76610 also suggested avoiding the trig. We've decided to leave it in as an example. If someone comes across this code and has never done trig before, at least they have the example they can copy and paste at the beginning. Then, we hope it encourages them to continue studying. This achieves our larger goals for the book. We're going to leave it as is.
12SUGGEST

Trig not required. See /photostream/#A2GfnH8tGErhQy at icloud.com for handwritten notes.

2014-04-29Addressed in #76734.
71ERROR

While working on chapter 4, I noticed that after I completed step 4-6, if I tap on the screen multiple times to close the “star wars” style text crawl, the game crashes.

I tried this with the sample code, and noticed the same issue happened vs. what I was building as I went through the book (if it helps, I’m using Xcode 6.1 beta). Looking at the issue more closely using NSLog statements to see when the “endScene” vs. “willMoveFromView” methods were being called, I noticed that “endScene” was called first as expected, but that doesn’t remove the Gesture Recognizer. “willMoveFromView” was called shortly afterwords, but the delay was noticeable (around a second on my iMac).

With the delay to remove the tap gesture recognizer as a possible cause of the crash, I tried rebuilding the program with the following revisions to “endScene” (and commented the respective lines out in “willMoveFromView” method), and the program no longer crashed due to repeated taps:

- (void) endScene
{
[UIView animateWithDuration:.3 animations:^{
self.textView.alpha = 0;
} completion:^(BOOL finished) {
[self.textView.layer removeAllAnimations];
NSAssert(self.sceneEndCallback, @“Scene end callback not set.”);
self.sceneEndCallback();
}];

[self.view removeGestureRecognizer:self.tapGesture]; //Added; removed from “willMoveFromView”
self.tapGesture = nil; //Added; removed from “willMoveFromView”

}

I hope this helps, and thanks for looking into this!

Categories: