How to replace sprite image for cocos2d-html5 2.2.3

I am looking for a way to replace the cc.Sprite image? Can anyone help? The images are not in the plist.

Thanks.

you can use cc.Sprite.create() again.

You mean change the texture ?

Create new sprite does not work. I need to change the texture of the sprite.

Pandamicro, yes, I need to change the texture of the sprite, with the individual image file, not the plist file made from texturepack. I am working on the offline engine which has limitation about the plist, fnt, etc. Thank.

Try this:

sprite.setTexture(newTex);
sprite.setTextureRect(cc.rect(0, 0, w, h));

setTextureRect is needed to really update the texture

1 Like

how to do this in cocos2dx v3