From 1cd07dc217e2b116d2b6a5fd919764b1c491acf5 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Fri, 12 Oct 2001 00:36:03 +0000 Subject: [PATCH] Notify sprites when a new path is begun. Made time-based animation work. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@445 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/media/sprite/Sprite.java | 14 +++++++++++--- .../com/threerings/media/util/LineSegmentPath.java | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/java/com/threerings/media/sprite/Sprite.java b/src/java/com/threerings/media/sprite/Sprite.java index 0df108c1b..1fc613f7e 100644 --- a/src/java/com/threerings/media/sprite/Sprite.java +++ b/src/java/com/threerings/media/sprite/Sprite.java @@ -1,5 +1,5 @@ // -// $Id: Sprite.java,v 1.23 2001/09/17 23:55:45 shaper Exp $ +// $Id: Sprite.java,v 1.24 2001/10/12 00:36:03 shaper Exp $ package com.threerings.media.sprite; @@ -327,6 +327,14 @@ public class Sprite _path = null; } + /** + * Called by the active path when it begins. + */ + protected void pathBeginning () + { + // nothing for now + } + /** * Called by the active path when it has completed. */ @@ -377,7 +385,6 @@ public class Sprite public void tick (long timestamp) { int fcount = _frames.getFrameCount(); - int nfidx = _frameIdx; boolean moved = false; // move the sprite along toward its destination, if any @@ -386,13 +393,14 @@ public class Sprite } // increment the display image if performing image animation + int nfidx = _frameIdx; switch (_animMode) { case NO_ANIMATION: // nothing doing break; case TIME_BASED: - _frameIdx = (int)((timestamp/_frameDelay) % fcount); + nfidx = (int)((timestamp/_frameDelay) % fcount); break; case MOVEMENT_CUED: diff --git a/src/java/com/threerings/media/util/LineSegmentPath.java b/src/java/com/threerings/media/util/LineSegmentPath.java index 2543d68da..d80e308d1 100644 --- a/src/java/com/threerings/media/util/LineSegmentPath.java +++ b/src/java/com/threerings/media/util/LineSegmentPath.java @@ -1,5 +1,5 @@ // -// $Id: LineSegmentPath.java,v 1.10 2001/09/17 23:55:45 shaper Exp $ +// $Id: LineSegmentPath.java,v 1.11 2001/10/12 00:36:03 shaper Exp $ package com.threerings.media.sprite; @@ -111,6 +111,9 @@ public class LineSegmentPath implements Path // documentation inherited public void init (Sprite sprite, long timestamp) { + // give the sprite a chance to perform any starting antics + sprite.pathBeginning(); + // if we have only one node then let the sprite know that we're // done straight away if (size() < 2) {