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

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

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

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ā€"

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:

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

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)

typo Page 40 (ePub)

iamge

instead of ā€œimageā€

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
2 Likes