You all know how to add an Image to a sprite. But what if we need to change the image of the same sprite? How to do that?
Use the following line of code to change the image of a sprite which already initialized with a sprite.

[sampleSprite setTexture:[[CCTextureCache sharedTextureCache] addImage:@"newImage.png"]];

where sampleSprite is the name of your sprite and newImage is the new image you want to replace with!



Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.