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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // 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 } |