S
S
Stanislav Korolevskiy2015-12-21 19:51:48
Swift
Stanislav Korolevskiy, 2015-12-21 19:51:48

How to speed up the movement of an object?

You can move an object in the scene with your finger. But if you slightly accelerate the movement of your finger across the screen, the object remains in place. Is it possible to speed up his movement speed? Duration already set to 0

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
        
        let touch = touches.first
        let touchLocation = touch!.locationInNode(self)
        let node = self.nodeAtPoint(touchLocation)
        
        if (node.name == "circle") {
            
            let moveAction = SKAction.moveTo(touchLocation, duration: 0)
            
            figureUser.runAction(moveAction)
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Korolevskiy, 2015-12-21
@korolevsky_s

var movingNode : SKNode?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)     {

    let touch = touches.first
    let touchLocation = touch!.locationInNode(self)
    let node = self.nodeAtPoint(touchLocation)

    if (node.name == "circle") {
        movingNode = node
        let moveAction = SKAction.moveTo(touchLocation, duration: 0)

        figureUser.runAction(moveAction)
    }
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?)     {

    let touch = touches.first
    let touchLocation = touch!.locationInNode(self)

        let moveAction = SKAction.moveTo(touchLocation, duration: 0)

        figureUser.runAction(moveAction)

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question