SpriteKit SKTextures
SpriteKit SKTextures
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)
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)