B.Toaster
B.Toaster

Reputation: 169

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)
            }
        }
    }

The issue here is about the textures. I can't figure out how to properly take the towers texture and make the buildingExample have it's same texture. Currently, the building example is not visibly appearing on the screen.

Upvotes: 1

Views: 48

Answers (1)

Maetschl
Maetschl

Reputation: 1339

Replace:

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

For:

            let buildingExample = SKSpriteNode(texture: tower.texture)

Upvotes: 1

Related Questions