is there a way to check if a gif finished the animation? the problem is that the gif is looping, and i want to remove it after it's over.
// fields
private boolean isFirstImage;
private GreenfootImage firstImage;
private GifImage gif = ...;
// in act
setImage(gif.getCurrentImage()); // update image
if (firstImage == null) // initializing (only executed during first act step)
{
firstImage = getImage(); // retain first image
isFirstImage = true; // set tracking field
}
if (isFirstImage != (getImage() == firstImage)) // if an image change involved first image
{
isFirstImage = ! isFirstImage; // toggle tracking field
if (isFirstImage) getWorld().removeObject(this); // if returning to first image, remove this
}