gpt4 book ai didi

ios - 在 SpriteKit 的不同屏幕上为节点大小定义变量的最佳方法

转载 作者:可可西里 更新时间:2023-10-31 23:44:24 25 4
gpt4 key购买 nike

我正在用 SpriteKit 制作游戏。对于将要在我的场景中使用的不同节点,我有不同的类。我需要让我的游戏具有通用性,以便它适应每个屏幕。定义我将在不同类和主场景中使用的不同变量的最佳方法是什么。

最佳答案

然后初始化您的节点,您可以创建您的world SKNode 参数,然后访问您的world.frame.size

class NodeClass: SKSpriteNode {

init(world: SKNode) {

super.init(texture: nil,
color: UIColor.clearColor(), size:
CGSizeMake(world.frame.size.width / 24, world.frame.size.width / 24))
}
}

您还可以设置 position 和 movament,根据您的场景大小进行缩放。

关于ios - 在 SpriteKit 的不同屏幕上为节点大小定义变量的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34029231/

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