Macehil
Macehil

Reputation: 69

Long tap recognizer in Sprite Kit with swift

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! :)

Upvotes: 1

Views: 332

Answers (2)

Daniel Mihaila
Daniel Mihaila

Reputation: 585

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

}

Upvotes: 0

Leo Dabus
Leo Dabus

Reputation: 236370

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

Upvotes: 2

Related Questions