2017-03-15 68 views
1

我在Mac上使用了swift遊樂場,並選擇了macOS選項來製作應用程序。我做了一個SKSpriteNode成圖像的設置skNodeButton.isUserInteractionEnabled = true但是我不能使用的UIKit所以它不會允許我用平時override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)如何在不使用UIKit的情況下處理點擊SKSpriteNode

反正有我可以得到可可或任何其他框架點擊節點?

回答

1

在macOS上,SKSpriteNode繼承自NSResponder。您可以覆蓋像mouseDown(with:NSEvent), mouseUp, mouseMoved等方法。

這是documentation

+0

它的工作原理感謝 – Tim2799

+0

等不知道它不是 – Tim2799

+0

它必須重寫嗎? – Tim2799

相關問題