touchesMoved:如何知道触摸何时结束?
touchesMoved: How to know when the touch ended?
我有一个球,我想四处移动 (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
}
我有一个球,我想四处移动 (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
}