Reputation: 231
I defined SKSpriteNode under SKScene class, how can i change the SKSpriteNode image afterwards, for example:
class GameScene: SKScene {
var player = SKSpriteNode(imageNamed: "player")
}
I want to change the image from "player" to "player1" during some action. I do not inherit SKNode class, so i can not use SKTexture method to do it.
Upvotes: 9
Views: 9309
Reputation: 6951
SKScene
is a subclass of SKNode
so you do in fact inherit it. You can use SKTexture
to change the image like this:
player.texture = SKTexture(imageNamed: "player1")
Upvotes: 24