Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing image of a skspritenode()

This is how I add my player's texture/image:

Player = SKSpriteNode(imageNamed:"player8")

How do I change the players texture/image without adding or deleting spritenodes?

like image 859
DNC Avatar asked Nov 30 '22 18:11

DNC


1 Answers

You assign a different texture:

player = SKSpriteNode(imageNamed:"player8")

Sometime later:

player.texture = SKTexture(imageNamed:"player123")

Hint: it is bad style to begin variable, property and method names with an uppercase character as it makes them appear to be classes.

like image 131
LearnCocos2D Avatar answered Dec 04 '22 13:12

LearnCocos2D