【发布时间】:2015-10-11 07:34:45
【问题描述】:
我有一个SKSpriteNode,我想通过touchesMoved 在屏幕上拖动它。但是,如果触摸最初不是源自精灵的位置(不跳过场景),我不希望精灵移动。
我有一个间歇性的解决方案,但我认为有些东西更优雅,更实用,因为这个解决方案不能正常工作 - 如果用户非常拖动精灵,精灵位置似乎跟不上触摸位置快。
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
var touchPoint : CGPoint = location
var muncherRect = muncherMan.frame
if (CGRectContainsPoint(muncherRect, touchPoint)) {
muncherMan.position = location
} else {
}
}
}
【问题讨论】:
标签: ios swift sprite-kit swift2 skspritenode