繁体   English   中英

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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM