Change animation of an sprite ( change current image frames for other image frames )

ship
i have an sprite that is instantiated with different frames , the issue i have is that i want to use another animation ( explosion animation ) that is in a different image strip, and i also have other 2 images for enemies, i would like to use the same explosion animation for all the sprites, i know i can add the explosion animation to every image strip ( ship, enemy1 and enemy2), but has different measures, i was wondering if there is a function or a way to set a new animation to an sprite, basically is to change the animation or frames of the current sprite i want to destroy ( or explode ) and make it invisible after animation end.

how do you handle that, without creating another sprite just for the explosion?

You could hide the ship/enemy sprite by setting its width or height to zero, and show a separate explosion sprite in its place.

Example: https://playground.babylonjs.com/#YCY2IL#2332.

yeah, i was thinking to create other explosion sprites and switch them , but that implies to have same number of explosion sprites as enemies.

i was wondering if there was just a way to set new frames to current sprite.

that would work with SpritePackedManager, but it has a bug that you cannot play frame animations.

Please reproduce the bug in a playground and we’ll investigate.

1 Like

if you mean the bug with SpritePackedManager, i already have another thread where i provided the project and images

Is that this one here:

I investigated and responded in the other thread.