Changing image of a skspritenode()

淺唱寂寞╮ 提交于 2019-12-10 17:22:07

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27460191/changing-image-of-a-skspritenode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!