简体   繁体   中英

touchesMoved: How to know when the touch ended?

I have a ball that I want to move around (Spritekit) and I want to set a velocity so when the player move the ball then he moves his finger from the screen the ball will move and it will have it's own velocity depinding on some calculations

the question : this is my code , how can I know when the player is moving his finger from the screen ?!

override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {

        if let touch = touches.first as? UITouch{
            var location = touch.locationInNode(self)
            ball6.position = location
        }

Use this method:

override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
    //your code
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM