I've tried
[[CCTextureCache sharedTextureCache] addImage: @"still.png"];
But I always end up with a distorted image for some reason. It's most likely because my images are not the same resolution, but for this app, they can't have the same res. How do I change the sprite's image without going through the complicated process of making a spritesheet or an animation or any of that.
urSprite = [CCSprite spriteWithFile:@"one.png"]; urSprite.position = ccp(240,160); [self urSprite z:5 tag:1]; // Changing the image of the same sprite [urSprite setTexture:[[CCTextureCache sharedTextureCache] addImage:@"two.png"]];
This is the most straight forward way to change the image of a sprite(if you have it loaded trough a spritesheet) this definitely works (I use it all the time in my game). mySprite is the name of the sprite instance:
[mySprite setDisplayFrame:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"sprite1.png"] ];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With