gpt4 book ai didi

swift - SpriteKit SKTextures

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

        for building in self.buildingArray {
if building.contains(location) {
upgradeArray.removeAll()
upgradeArray.append(building)
for tower in self.upgradeArray {
print(tower.position.x)
let buildingExample = SKSpriteNode()
buildingExample.texture = tower.texture
buildingExample.position.y = spikeTowerOption.position.y
buildingExample.position.x = 0
buildingExample.zPosition = 20
buildingExample.setScale(frame.size.height/3700)
self.addChild(buildingExample)
}
}
}

这里的问题是关于纹理。我不知道如何正确地获取塔的纹理并使 buildingExample 具有相同的纹理。目前,建筑示例并未明显出现在屏幕上。

最佳答案

替换:

            let buildingExample = SKSpriteNode()
buildingExample.texture = tower.texture

对于:

            let buildingExample = SKSpriteNode(texture: tower.texture)

关于swift - SpriteKit SKTextures,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45289635/

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