Long tap recognizer in Sprite Kit with swift

362 views Asked by At

Hello I'm planning a game and an essential part of the game is to move left and right by pressing the right side of the screen or the left side.

But how can I detect a long press?

Many Thanks! :)

2

There are 2 answers

0
Leo Dabus On

It is not called long tap. A tap can't be long. It is called UILongPressGestureRecognizer. You can take a look at the documents here

0
Daniel Mihaila On

if you want to do something while the user is holding down on the screen, you could use the touchesBegan and touchesEnded methods to detect the hold.

var touching = false 

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

touching = true


}

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

touching = false

}