Search code examples
swift3sprite-kittouchesbegan

Moved character on swift3 SpriteKit


I have a serious problem, I practice, but Ball does not move. I also experienced this problem in another application.

XCode version: 8.2.1

Please help me. I can not make progress.

watching tutorial download the project; it's work!

I created in the course. it's not work!!

download my project : Https://yadi.sk/d/TPN6OGrV3Gz7rq

my code

GameScene.sks image enter image description here

GameScene.swift file

import SpriteKit
import GameplayKit

class GameScene: SKScene {

    var ball:SKSpriteNode!
    var paddle:SKSpriteNode!

    override func didMove(to view: SKView) {
        ball = self.childNode(withName: "Ball") as! SKSpriteNode
        paddle = self.childNode(withName: "Paddle") as! SKSpriteNode

        ball.physicsBody?.applyImpulse(CGVector(dx: 50, dy: 50))

    }
}

Solution

  • change

    if let scene = SKScene(fileNamed: "GameScene")
    

    to

    if let scene = GameScene(fileNamed: "GameScene")
    

    I ran your project on my computer and when changing that line the ball moved as expected