Java 图像加载、视觉效果与动画实现详解
1. ImagesPlayer 对象实现细节
ImagesPlayer 对象维护了一个 animTotalTime
变量,用于记录自对象创建以来的当前时间(以毫秒为单位)。当 updateTick()
方法被调用时,该变量会增加:
public void updateTick()
// I assume that this method is called every animPeriod ms
{
if (!ticksIgnored) {
// update total animation time, modulo seq duration
animTotalTime = (animTotalTime + animPeriod) %
(long)(1000 * seqDuration);
// calculate current displayable image position
imPosition = (int) (animTotalTime / showPeriod);
if ((imPosition == numImages-1) && (!isRepeating)) { //seq end
ticksIgnored = true; // stop at this image
if (watcher != null)
watcher.sequenceEnded(i