gpt4 book ai didi

swift - 如何使用 swift 使车辆或火车在 iOS Sprite Kit Game 中的场景中移动

转载 作者:行者123 更新时间:2023-11-30 13:41:44 25 4
gpt4 key购买 nike

我正在尝试在 swift 的 sprite kit 游戏场景中使用字母列车实现 iOS 应用程序。我不知道如何保持 Sprite 节点火车轮旋转并将其与火车 Sprite 节点连接,以实现真正的火车在场景中的移动。我可以创建 Sprite 节点并正确呈现场景,但不确定正确的方法处理,即火车和车轮连接并一起移动。除了 SKActions 之外,我还需要使用任何额外的东西吗?谢谢。

最佳答案

您可以将车轮和火车的所有部件添加为代表整个火车的主 SKNode 的子节点。您可以将其移动到屏幕上并简单地处理轮子上的旋转。

let train = SKNode()    // add move actions to this
let wheel = SKSPriteNode(imageNamed: "wheel") // add rotation actions to this
train.addChild(wheel)

关于swift - 如何使用 swift 使车辆或火车在 iOS Sprite Kit Game 中的场景中移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35491515/

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