I have an object that inherited from CCSprite. I want from inside this object to change the image.
How do I change the image (sprite) without creating a new CCSprite object in Cocos2d-X?
Thanks, Adrian.
I have an object that inherited from CCSprite. I want from inside this object to change the image.
How do I change the image (sprite) without creating a new CCSprite object in Cocos2d-X?
Thanks, Adrian.
I found out, and I leave it here in case somebody gets stuck with the same problem:
Inside your object that's inherited from CCSprite object, write a function as follows
Since "CCTextureCache::sharedTextureCache()" is now deprecated (v.3.13.1) you'd better get the texture cache from the Director:
Source: http://www.cocos2d-x.org/wiki/Texture_Cache
Works for me:
Before you need to load you sprites in cache:
No need to alter your custom class.. Hope this helps.. :)