如何在启动OSX spritekit应用程序时设置自定义光标?

时间:2015-04-24 03:22:21

标签: swift macos sprite-kit cursor

所以我想在我的spritekit游戏中使用自定义光标。我只能通过将其添加到我的第一个场景来实现它的工作:

override func mouseEntered(theEvent: NSEvent) {
    let myCursor: NSCursor = NSCursor(image: NSImage(named: "cursor")!, hotSpot: NSPoint(x: 0.5, y: 0.5))
    self.view?.addCursorRect(self.frame, cursor: myCursor)
}

但是,在我点击两次并移动鼠标之前,这不会将光标更改为我的自定义光标。我真正想要的是在应用程序启动后立即显示新光标。有任何想法吗?在ApplicationDidFinishLaunching中添加游标不起作用。

1 个答案:

答案 0 :(得分:0)

通过将您的代码放入sprite kit的didMoveToView函数,它对我有用:

xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"