I’ve made it up to page 58, but when I build and run, the zombie just sits there and does nothing.
Suggestions on what might be wrong?
Here is the code:
import SpriteKit
class GameScene: SKScene {
let zombie = SKSpriteNode(imageNamed: "zombie1")
override func didMove(to view: SKView) {
backgroundColor = SKColor.black
let background = SKSpriteNode(imageNamed: "background1")
let zombie = SKSpriteNode(imageNamed: "zombie1")
//zombie.setScale(2)
zombie.position = CGPoint(x: 400, y: 400)
//background.position = CGPoint(x: size.width / 2, y: size.height / 2)
background.anchorPoint = CGPoint(x: 0.5, y: 0.5)
background.position = CGPoint(x: size.width / 2, y: size.height / 2)
//background.zRotation = CGFloat(M_PI) / 8
background.zPosition = -1
addChild(background)
addChild(zombie)
}
override func update(_ currentTime: TimeInterval) {
zombie.position = CGPoint(x: zombie.position.x + 8, y: zombie.position.y)
}
}