Hello,
I am working on the code at the bottom of page 61 where we are trying to get the zombie to move along the x axis. One error it gives me is that “override” should not be a part of the code given in the section:
"
override func update(_ currentTime: TimeInterval) {
zombie.position = CGPoint(x: zombie.position.x + 8,
}
"
I remove the “override” and it removes the error. I build and run the simulation, but the zombie still does not move. Any ideas on what is going wrong? My code is pasted below. Thanks in advance!
import SpriteKit
class GameScene: SKScene {
// Challenge 1: Create the zombie and position it at (400, 400)
let zombie = SKSpriteNode(imageNamed: "zombie1")
override func didMove(to view: SKView) {
backgroundColor = SKColor.black
let background = SKSpriteNode(imageNamed: "background1")
//background.position = CGPoint(x: size.width/2, y: size.height/2)
background.anchorPoint = CGPoint.zero
background.position = CGPoint.zero
background.zPosition = -1
addChild(background)
let mySize = background.size
print("Size: \(mySize)")
zombie.position = CGPoint(x: 400, y: 400)
addChild(zombie)
func update(_ currentTime: TimeInterval) {
zombie.position = CGPoint(x: zombie.position.x + 8,
y: zombie.position.y)
}
}
}