mtkView(_ _: MTKView, drawableSizeWillChange Size: CGSize) 是更新跟踪区域的好地方吗?
Is mtkView(_ _: MTKView, drawableSizeWillChange Size: CGSize) an OK place to update tracking areas?
由于将class从MTKView
改成我自己的看法比较不方便,覆盖代码插入updateTrackingAreas()
代码,只是为了检测鼠标移动事件,这样做可以吗?
func mtkView(_ _: MTKView, drawableSizeWillChange Size: CGSize) {
if let TrackingArea = Area {
View.removeTrackingArea(TrackingArea)
}
Area = NSTrackingArea(rect: View.bounds, options: [.mouseEnteredAndExited, .mouseMoved, .activeInKeyWindow], owner: View, userInfo: nil)
View.addTrackingArea(Area!)
/*ProjectionMatrix = ProjectPerspective(Float(Size.width/Size.height))
View.draw()*/
}
有没有更好的方法在 Metal 游戏中实现跟踪区域? (希望如此)
嗯,为了安全起见,我决定将它们放在 updateTrackingAreas
由于将class从MTKView
改成我自己的看法比较不方便,覆盖代码插入updateTrackingAreas()
代码,只是为了检测鼠标移动事件,这样做可以吗?
func mtkView(_ _: MTKView, drawableSizeWillChange Size: CGSize) {
if let TrackingArea = Area {
View.removeTrackingArea(TrackingArea)
}
Area = NSTrackingArea(rect: View.bounds, options: [.mouseEnteredAndExited, .mouseMoved, .activeInKeyWindow], owner: View, userInfo: nil)
View.addTrackingArea(Area!)
/*ProjectionMatrix = ProjectPerspective(Float(Size.width/Size.height))
View.draw()*/
}
有没有更好的方法在 Metal 游戏中实现跟踪区域? (希望如此)
嗯,为了安全起见,我决定将它们放在 updateTrackingAreas