ios - 触摸已移动 : How to know when the touch ended?

标签 ios swift sprite-kit

我有一个想要移动的球(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/

相关文章:

swift - 从 Swift 运行 AppleScript 不工作

ios - 是否可以调整里面有小图片的textview?

swift - UIImages 后面的 SpriteNode

ios - 问题连接到 iTunes 连接

c# - Xamarin.iOS 的像素转换距离

ios - 以某种方式生成 AVPlayerItem 的副本而不是访问引用

ios - 如何使用Swift SpriteKit在For循环中一一创建SKSprite节点

ios - 项目在新的 XCode 6 中运行后出现 144 次致命故障

ios - 如何切换音频输出以通过扬声器播放?

ios - 在 UITabBarController 中的 ViewController 中呈现 View