From 5e286e5bab59328aedc29f5b766999af57aad2fe Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Tue, 17 Sep 2002 02:34:05 +0000 Subject: [PATCH] added TIME_SEQUENTIAL animation mode which shows frame 0 first, and for the full duration. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1687 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/media/sprite/ImageSprite.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/media/sprite/ImageSprite.java b/src/java/com/threerings/media/sprite/ImageSprite.java index 12ccf1804..c0f8579d7 100644 --- a/src/java/com/threerings/media/sprite/ImageSprite.java +++ b/src/java/com/threerings/media/sprite/ImageSprite.java @@ -1,5 +1,5 @@ // -// $Id: ImageSprite.java,v 1.10 2002/07/08 21:15:35 mdb Exp $ +// $Id: ImageSprite.java,v 1.11 2002/09/17 02:34:05 ray Exp $ package com.threerings.media.sprite; @@ -38,6 +38,11 @@ public class ImageSprite extends Sprite /** Animation mode indicating time based animation. */ public static final int TIME_BASED = 2; + /** Animation mode indicating sequential progressive animation. + * Frame 0 is guaranteed to be shown first for the full duration, and + * so on. */ + public static final int TIME_SEQUENTIAL = 3; + /** * Constructs an image sprite without any associated frames and with * an invalid default initial location. The sprite should be populated @@ -221,7 +226,7 @@ public class ImageSprite extends Sprite if (_frames == null) { return; } - + int fcount = _frames.getFrameCount(); boolean moved = false; @@ -241,6 +246,13 @@ public class ImageSprite extends Sprite nfidx = (int)((timestamp/_frameDelay) % fcount); break; + case TIME_SEQUENTIAL: + if (_firstStamp == 0L) { + _firstStamp = timestamp; + } + nfidx = (int) (((timestamp - _firstStamp) / _frameDelay) % fcount); + break; + case MOVEMENT_CUED: // update the frame if the sprite moved if (moved) { @@ -273,6 +285,9 @@ public class ImageSprite extends Sprite /** For how many milliseconds to display an animation frame. */ protected long _frameDelay; + /** The first timestamp seen (in TIME_SEQUENTIAL mode). */ + protected long _firstStamp = 0L; + // /** DEBUG: The alpha level used when rendering our bounds. */ // protected static final Composite ALPHA_BOUNDS = // AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f);