Tim2799
Tim2799

Reputation: 71

How do you handle a click on an SKSpriteNode WITHOUT using UIKit

I am using swift playgrounds on a mac and I chose the macOS option to make the application. I made an SKSpriteNode into an image an is set skNodeButton.isUserInteractionEnabled = true However I can't use UIKit so it doesn't allow me to use the usual override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)

is there anyway I can get a clicked node with cocoa or any other framework?

Upvotes: 1

Views: 109

Answers (1)

Dave Weston
Dave Weston

Reputation: 6635

On macOS, SKSpriteNode inherits from NSResponder. You can override methods like mouseDown(with:NSEvent), mouseUp, mouseMoved, etc.

Here's the documentation.

Upvotes: 1

Related Questions