gpt4 book ai didi

swift 3 SKAction 速度属性

转载 作者:行者123 更新时间:2023-11-28 06:14:12 28 4
gpt4 key购买 nike

我试图改变 SKAction 动画的速度属性。我有几个带有小图像剪辑的菜单按钮(来自短视频剪辑)。现在我想改变这个剪辑的速度。首先,我尝试更改动画 SKAction 的 timePerSeconds,现在我发现 SKAction 本身有一个速度属性。

但是没什么,speed = 0.0 应该停止动画,我用 animate 或 repeatforever 部分试过了。有什么想法吗?

// all anim sequences in an array
var mainAktionArray = [SKAction()]


let menuAnimation = SKAction.animate(with: menuFrames, timePerFrame: frameTime )
let runForEver = SKAction.repeatForever(menuAnimation)
mainActionArray.append(runForEver)
menu.run(runForEver)


func setFrameRate(wert : Float32){

menuSpeed = CGFloat(wert)
menuSpeed = 0.0

for el in mainActionArray {
el.speed = menuSpeed
}
}

最佳答案

当你调用运行命令时,它里面的 Action 被复制到节点,它不是引用。 Action 是不可变的对象,允许它安全地跨多个节点使用。这允许您在多个节点上使用 1 个 Action 变量。

如果你想设置一个特定的速度,你需要把 Action 从你的节点中拉出来。为此,您需要通过 menu.run(runForEver,withKey"runForEver") 为它分配一个键,然后您可以使用 let action = menu.action(forKey: "runForEver") 然后设置 action.speed = 0

关于swift 3 SKAction 速度属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45608936/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com