下次触摸之前无法接收系统手势状态通知

时间:2018-06-22 18:29:20

标签: swift sprite-kit scenekit

我当前在SKSpriteNodes这两个按钮上使用触摸方法。我接收到手势状态失败,但是我不确定为什么,因为我没有使用手势,所以我将touchBegantouchEnded用于触摸控件。

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    for touch: AnyObject in touches {
        let pointTouched = touch.location(in: self)
        if leftArrow.contains(pointTouched) {
            moveWizard(moveBy: -60, forTheKey: "left")
            wizardRunAnimation(forTheKey: "wizardRun")
            wizardNode.xScale = -1
        }
        if rightArrow.contains(pointTouched) {
            moveWizard(moveBy: 60, forTheKey: "right")
            wizardRunAnimation(forTheKey: "wizardRun")
            wizardNode.xScale = 1
        }
        if attackButton.contains(pointTouched) {
            wizardAttackAnimation()
        }
    }
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
    wizardNode.removeAction(forKey: "left")
    wizardNode.removeAction(forKey: "right")
    wizardNode.removeAction(forKey: "wizardRun")
}

0 个答案:

没有答案