tk2d change tk2dSprite's Sprite value at runtime

Hi

I have a tk2dsprite that is showing correctly inside a gameobject at runtime, but I would like to change the Sprite to another image in the same collection at runtime. Is this possible, an if so…how?

Any help would be greatly appreciated, thanks!

I actually got a reply from the creator. The most efficient way to handle this is by: iconSprite.spriteId = iconSprite.GetSpriteIdByName(“iconName”);

You only have to change the spriteId property of the thesprite, and you can pass the sprite name with GetSpriteIdByName() to get the id :slight_smile:

Personally i would simply create an animation of the two sprites, this would allow you to call the animation when nessecary within your code which in turn would change your sprite.

Also you can set property for that Sprite if you want to change SpriteCollection, where it will search sprite with yours new spriteId