Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANDROID ANDENGINE -- change sprite on action down

I have in my app some sprites. When I touch a sprite (in TouchEvent.isActionDown() ) , I need to change its image

How can I made this?

like image 658
NemoPhobia Avatar asked Dec 22 '25 02:12

NemoPhobia


1 Answers

I'm not familiar with AndEngine, but by the looks of it, the Sprite class does not provide the functionality to change its image - or better said: texture. However, you might be able to accomplish your goal by using the TiledSprite or AnimatedSprite.

The latter is an extension of the first, so you should be able to use a TiledSprite. It has setCurrentTileIndex() and nextTile methods that seem to allow you to swap out one texture region by another. You may need to modify your images into a format suitable for AndEngine though and obviously you will need a handle to the touched sprite.

like image 143
MH. Avatar answered Dec 24 '25 20:12

MH.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!