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)
}
}
}
这里的问题是关于纹理。我无法弄清楚如何正确地采取塔纹理并使建筑实例具有相同的纹理。目前,建筑示例并未明显出现在屏幕上。
答案 0 :(得分:1)
替换:
let buildingExample = SKSpriteNode()
buildingExample.texture = tower.texture
有关:
let buildingExample = SKSpriteNode(texture: tower.texture)