I bought 2D iOS & tvOs Games by tutorials a long time ago, and now I am reading it. I am disappointed there won’t be any new updates!
So, anyway I had the same problem that the zombie won’t move across the screen, it just stays in one spot.
I looked at the last solution that someone had the same problem and had to put the override fun update after the override func didMove curly brace }, but then I got an error about the zombie and figured it out that you have to make the variable let zombie = SKSpriteNode(imageNamed: “zombie1”) a global variable.
Here is the solution:
import SpriteKit
import GameplayKit
class GameScene: SKScene {
**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(x: 0.5, y: 0.5)
background.position = CGPoint(x: size.width / 2, y: size.height / 2)
// background.zRotation = CGFloat.pi / 8
background.zPosition = -1
addChild(background)
let mySize = background.size
print("Size: \(mySize)")
zombie.position = CGPoint(x: 400, y: 400)
//zombie.setScale(2)
addChild(zombie)
}
**override func update(_ currentTime: TimeInterval) { zombie.position = CGPoint(x: zombie.position.x + 8,**
** y: zombie.position.y)**
}
}