Sprite.setImage() in andengine

andengine, android, sprite

Solution

I think use TextureRegion is a better way to change sprite's image.

Add the following code in org.anddev.andengine.entity.sprite

public void setTextureRegion(TextureRegion textureRegion) {
    this.mTextureRegion = textureRegion;
}

Then you can change image by this method. You can check the andengine samples to see how to create a texture region from an image.

PS, if `mTextureRegion` is final, just remove the `final` syntax.

Problem

I'm developing a game for Android using andEngine. I have to change sprite images dynamically. In J2ME, i used ``` sprite.setImage("img.png"); ``` But in andengine, i not able to find method ``` //sprite.setImage(?); -In andengine ``` Any solutions ?

Original source

Related problems