Have to initialize our path on the first call to tick() now.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1976 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageSprite.java,v 1.15 2002/10/08 21:03:37 ray Exp $
|
// $Id: ImageSprite.java,v 1.16 2002/11/20 05:33:20 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.sprite;
|
package com.threerings.media.sprite;
|
||||||
|
|
||||||
@@ -240,9 +240,7 @@ public class ImageSprite extends Sprite
|
|||||||
boolean moved = false;
|
boolean moved = false;
|
||||||
|
|
||||||
// move the sprite along toward its destination, if any
|
// move the sprite along toward its destination, if any
|
||||||
if (_path != null) {
|
moved = tickPath(timestamp);
|
||||||
moved = _path.tick(this, timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// increment the display image if performing image animation
|
// increment the display image if performing image animation
|
||||||
int nfidx = _frameIdx;
|
int nfidx = _frameIdx;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Sprite.java,v 1.52 2002/11/05 03:38:59 mdb Exp $
|
// $Id: Sprite.java,v 1.53 2002/11/20 05:33:20 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.sprite;
|
package com.threerings.media.sprite;
|
||||||
|
|
||||||
@@ -215,11 +215,10 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
*/
|
*/
|
||||||
public void move (Path path)
|
public void move (Path path)
|
||||||
{
|
{
|
||||||
// initialize the path
|
// save off this path
|
||||||
path.init(this, System.currentTimeMillis());
|
|
||||||
|
|
||||||
// and save it off
|
|
||||||
_path = path;
|
_path = path;
|
||||||
|
// we'll initialize it on our next tick thanks to a zero path stamp
|
||||||
|
_pathStamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,10 +265,27 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void tick (long tickStamp)
|
public void tick (long tickStamp)
|
||||||
{
|
{
|
||||||
// if we've a path, move the sprite along toward its destination
|
tickPath(tickStamp);
|
||||||
if (_path != null) {
|
}
|
||||||
_path.tick(this, tickStamp);
|
|
||||||
|
/**
|
||||||
|
* Ticks any path assigned to this sprite.
|
||||||
|
*
|
||||||
|
* @return true if the path relocated the sprite as a result of this
|
||||||
|
* tick, false if it remained in the same position.
|
||||||
|
*/
|
||||||
|
protected boolean tickPath (long tickStamp)
|
||||||
|
{
|
||||||
|
if (_path == null) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize the path if we haven't yet
|
||||||
|
if (_pathStamp == 0) {
|
||||||
|
_path.init(this, _pathStamp = tickStamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _path.tick(this, tickStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -341,4 +357,7 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
|
|
||||||
/** When moving, the path the sprite is traversing. */
|
/** When moving, the path the sprite is traversing. */
|
||||||
protected Path _path;
|
protected Path _path;
|
||||||
|
|
||||||
|
/** The timestamp at which we started along our path. */
|
||||||
|
protected long _pathStamp;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user