Game Development Reference
In-Depth Information
-((self.playerNode!.position.y
- 180.0)/8));
self.backgroundStarsNode!.position =
CGPointMake(self.backgroundStarsNode!.position.x,
-((self.playerNode!.position.y
- 180.0)/6));
self.backgroundPlanetNode!.position =
CGPointMake(self.backgroundPlanetNode!.position.x,
-((self.playerNode!.position.y
- 180.0)/8));
self.foregroundNode!.position =
CGPointMake(self.foregroundNode!.position.x,
-(self.playerNode!.position.y
- 180.0));
}
else if self.playerNode!.position.y > 7000.0 {
self.gameOverWithResult(true)
}
else if self.playerNode!.position.y
+ self.playerNode!.size.height < 0.0 {
self.gameOverWithResult(false)
}
removeOutOfSceneNodesWithName("BLACK_HOLE")
removeOutOfSceneNodesWithName("POWER_UP_ORB")
}
}
The new update() method now calls the removeOutOfSceneNodesWithName()
method at the end of every scene rendering, removing all unnecessary nodes. Make this
change to the update() method and run the SuperSpaceMan game one last time. When
you play the game this time, tap the screen until you are about to win the game and then
stop tapping so that the playerNode starts to fall. Notice this time that as you fall, the
passed-up orb and black hole nodes have been removed from the scene.
Summary
Search WWH ::




Custom Search