【发布时间】:2014-09-05 13:08:13
【问题描述】:
我的 SpriteKit Mac 应用程序通过 -touchesBeganWithEvent:(NSEvent)event 响应 NSTouch 事件。但是,调用 -locationInNode 只会给我该 NSTouch 的鼠标坐标位置。但我正在尝试将触控板上的触摸坐标映射到屏幕,如下所示:
NSTouch *touch = [touches anyObject];
CGPoint sceneCoord;
sceneCoord.x = touch.normalizedPosition.x * self.size.width;
sceneCoord.y = touch.normalizedPosition.y * self.size.height;
这会将触控板坐标转换为窗口/场景坐标。但我需要知道场景中一个 SKNode 中的触摸位置。对于鼠标点击,我只使用 [event locationInNode:theNode],但我不能使用该调用,因为我正在手动计算上面的事件坐标。
我很惊讶 SpriteKit 没有任何处理 NSTouches 的调用。
【问题讨论】:
-
你是如何让你的场景响应 -touchesBeganWithEvent: 的?
标签: macos cocoa-touch sprite-kit nsevent nstouch