Group Group Group Group Group Group Group Group Group

Errata for 2D iOS & tvOS Games by Tutorials v1.3

#1

This topic is for bugs, typos, and other mistakes in 2D iOS & tvOS Games by Tutorials v1.3.

pinned #2
#3

I have asked a question there over a week ago with no reply

#4

Bug report by Gionata R: "At page 424 you provide the source code that interprets the accelerometer’s input. This piece of code, in my case, had been generating a strong reference cycle with its parent class, so that when I wanted to transition into another scene, my GameScene’s deinit wouldn’t be called.

I solved the problem by adding the [unowned self] capture list before the parameter list “accelerometerData, error in”"

#5

Submitted to our customer support desk by Billy:

Typo, 2D Apple Games, page 203

First, windWithTimer does not exist.
Second, there shouldn’t be an ‘s’ after switchWindDirections(_:slight_smile:

#6

There is a typo in the following paragraph on page 90 of 2D Apple Games by Tutorials v.2.0:

Here, you create the reverse of the actionMidMove and actionMove actions by calling reversed() on each, and insert them into the sequence.

insert should be inserting

#7

Page 525: There is an additional || os(tvOS) needed in update(_ ) in the update camera section.

Replace
#elseif os(OSX)

with
#elseif os(OSX) || os(tvOS)

#8

typo Page 40 (ePub)

iamge

instead of “image”

#10

Bug introduced by recommended code on Page 409 (PDF).

Then, in GameScene, replace didMove(to:) with this code:

override func didMove(to view: SKView) {
  if gameState == .initial {
    addChild(player)
    setupWorldPhysics()
    createBugs()
    setupObstaclePhysics()
    if firebugCount > 0 {
      createBugspray(quantity: firebugCount + 10)
    }
    setupHUD()
    gameState = .start
  }
  setupCamera()
}

There’s a line within the setupWorldPhysics() method that sets the GameScene class as the SKPhysicsContactDelegate. Since this was moved into a code block that only runs when the gameState == .initial then, when loading a saved game, the physics contact checking done in didBegin(contact:) is no longer firing, therefore you can’t eradicate Bugs in loaded saved games.

I resolved this by moving the following line out of the setupWorldPhysics() and put it right before setupCamera() in GameScene’s didMove(to:) so that it’s always run:

physicsWorld.contactDelegate = self
1 Like