Working on a designcode.io tutorial for making a SpriteKit game. Have an issue where adding player movement causes the player image/texture to disappear. Code snippet of the update() function below. Commenting out the last line player?.run(move)
keeps the "player" to remain visible within the view. Adding that line in the code makes the player disappear.
Any idea what's happening? Is the player being pushed off screen, masked by another object, or "invalidated" by the function in some way? I'm stumped.
extension GameScene {
override func update(_ currentTime: TimeInterval) {
let deltaTime = currentTime - previousTimeInterval
previousTimeInterval = currentTime
// Player movement
guard let joystickKnob = joystickKnob else { return }
let xPosition = Double(joystickKnob.position.x)
let displacement = CGVector(dx: deltaTime * xPosition * playerSpeed, dy: 0)
let move = SKAction.move(by: displacement, duration: 0)
player?.run(move)
}