触摸屏幕时仅在y方向上移动图像

时间:2019-07-13 19:25:25

标签: ios swift sprite-kit

我是iOS应用程序开发的新手,我很难编写一个脚本,当触摸屏幕时,该脚本将允许某个图像在y方向上跳转。我尝试使用touchesBegan,但是没有运气。任何帮助将不胜感激。

self.Sprite = self.childNode(withName: "//Ball") as? SKSpriteNode
if let Sprite = self.Sprite {
    let wait = SKAction.wait(forDuration: 3.0)
    let fade = SKAction.fadeIn(withDuration: 1.0)
    func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        let move = SKAction.moveBy(x: 0, y: 100, duration: 0.25)
        let sequence = SKAction.sequence([move])
        Sprite.run(sequence)
    }
}

0 个答案:

没有答案