When doing animation of ImageViews I use an implementation that extends ImageView then utilizes a Timeline that changes the Image field at some Duration. I could post the code for it but I think the constructor of said implementation says it all.....
public AnimatedImageView(int frameCount, Duration frameDelay, boolean infiniteLoop, ArrayList<Image> frames)
... I flip through the array of Images.
I recently came across this article on Java Code Geeks, http://bit.ly/IkZg0U . The approach outlined in the article uses a sprite sheet and the setViewPort method of the managed ImageView.
Taking into account that there will be dozens of these animated objects on screen at the same time, do you suspect a noticeable difference in performance between the two approaches? Which would you pick and why... or maybe you have a third approach?
What I like about the sprite sheet approach is that it lessens the number HTTP requests needed to retrieve the Images.
If switching of the images is fast enough and does not create any flickering then I
would go with your approach because the sprite approach will probably use a lot
more graphic memory. With your approach only the current image has to be in
graphic memory whereas for the sprite approach all images of a series have to
be in graphic memory at the same time.
In order to reduce the number of HTTP requests you could put all images of
a series into a zip file.
Thanks for the feedback. There is no flickering with my implementation.
I was going to post a new follow up question, but figure I ask you first... if I download a gzip via HTTP, is it possible to unzip it and put its image files into Image objects all while never touching the disk?