Detecting touch input on iOS devices

Other topics

Detecting touch

You can override 4 methods of SKScene to detect user touch

class GameScene: SKScene {
    

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

    }
    
    override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
        
    }
    
    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        
    }
    
    override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
    
    }
}

Please note that each method receives a touches parameter which (under particular circumstances) can contain more then one single touch event.

Contributors

Topic Id: 3660

Example Ids: 12591

This site is not affiliated with any of the contributors.