ImagesPlayer is aimed at displaying the sequence of images making up an
g set of images.
ImagesPlayer constructor takes the image's name, an
animPeriod value, a
seqDuration value, a Boolean indicating if the sequence should repeat, and a reference to the
ImagesPlayer player = new ImagesPlayer(imagesName, animPeriod, seqDuration, isRepeating, imsLoader);
seqDuration is the total time required to show the entire sequence. Internally, this is used to calculate
showPeriod, the amount of time each image will be the current one before the next image takes its place.
animPeriod states how often
updateTick() method will be called (the animation period).
updateTick() will be called periodically by the
update() method in the top-level animation framework.
The current time is calculated when
updateTick() is called and used to calculate
imPosition, which specifies which image should be returned when
getCurrentImage() is called. This process is illustrated in Figure 6-5.
This approach relies on the animation loop calling
updateTick() regularly at a fixed time interval, which is true for
ImagesTests. Another implicit assumption is that the
showPeriod time duration will be larger than
animPeriod. For example,
showPeriod might be in tenths of seconds even though
animPeriod may be in milliseconds. If
showPeriod is less than
animPeriod, then rendering progresses too slowly to display all
Figure 6-5. ImagesPlayer in use
the images within ...