我有一个想要移动的球(Spritekit),并且我想设置一个速度,这样当玩家移动球然后将手指从屏幕上移开时,球就会移动,并且它会有自己的速度,具体取决于一些计算
问题: 这是我的代码,我如何知道玩家何时将手指从屏幕上移开?!
override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
if let touch = touches.first as? UITouch{
var location = touch.locationInNode(self)
ball6.position = location
}
最佳答案
使用这个方法:
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
//your code
}
关于ios - 触摸已移动 : How to know when the touch ended?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28543736/