com.threerings.media.util
Interface Path

All Known Implementing Classes:
ArcPath, BobblePath, DelayPath, LinePath, LineSegmentPath, PathSequence, SmoothBobblePath, TilePath, TimedPath

public interface Path

A path is used to cause a Pathable to follow a particular path along the screen. The Pathable is responsible for calling tick(com.threerings.media.util.Pathable, long) on the path with reasonable frequency (generally as a part of the frame tick. The path is responsible for updating the position of the Pathable based on the time that has elapsed since the Pathable started down the path.

The path should call the appropriate callbacks on the Pathable when appropriate (e.g. Pathable.pathBeginning(), Pathable.pathCompleted(long)).


Method Summary
 void fastForward(long timeDelta)
          This is called if the pathable is paused for some length of time and then unpaused.
 void init(Pathable pable, long tickStamp)
          Called once to let the path prepare itself for the process of animating the supplied pathable.
 void paint(Graphics2D gfx)
          Paint this path on the screen (used for debugging purposes only).
 boolean tick(Pathable pable, long tickStamp)
          Called to request that this path update the position of the specified pathable based on the supplied timestamp information.
 void wasRemoved(Pathable pable)
          When a path is removed from a pathable, whether that is because the path was completed or because it was replaced by another path, this method will be called to let the path know that it is no longer associated with this pathable.
 

Method Detail

init

void init(Pathable pable,
          long tickStamp)
Called once to let the path prepare itself for the process of animating the supplied pathable. Path users should also call tick(com.threerings.media.util.Pathable, long) after init(com.threerings.media.util.Pathable, long) with the same initialization timestamp.


tick

boolean tick(Pathable pable,
             long tickStamp)
Called to request that this path update the position of the specified pathable based on the supplied timestamp information. A path should record its initial timestamp and determine the progress of the pathable along the path based on the time elapsed since the pathable began down the path.

Parameters:
pable - the pathable whose position should be updated.
tickStamp - the timestamp associated with this frame.
Returns:
true if the pathable's position was updated, false if the path determined that the pathable should not move at this time.

fastForward

void fastForward(long timeDelta)
This is called if the pathable is paused for some length of time and then unpaused. Paths should adjust any time stamps they are maintaining internally by the delta so that time maintains the illusion of flowing smoothly forward.


paint

void paint(Graphics2D gfx)
Paint this path on the screen (used for debugging purposes only).


wasRemoved

void wasRemoved(Pathable pable)
When a path is removed from a pathable, whether that is because the path was completed or because it was replaced by another path, this method will be called to let the path know that it is no longer associated with this pathable.