Added contains() and isMoving().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@836 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-19 07:43:09 +00:00
parent 049717d5ec
commit 6d350588c2
@@ -1,5 +1,5 @@
// //
// $Id: Sprite.java,v 1.32 2001/12/17 03:32:52 mdb Exp $ // $Id: Sprite.java,v 1.33 2001/12/19 07:43:09 mdb Exp $
package com.threerings.media.sprite; package com.threerings.media.sprite;
@@ -31,10 +31,10 @@ public class Sprite implements DirectionCodes
/** /**
* Constructs a sprite without any associated frames and with a * Constructs a sprite without any associated frames and with a
* default initial location of <code>(0, 0)</code>. The sprite * default initial location of <code>(0, 0)</code>. The sprite should
* should be populated with a set of frames used to display it via * be populated with a set of frames used to display it via a
* a subsequent call to {@link #setFrames}, and its location * subsequent call to {@link #setFrames}, and its location can be
* can be updated with {@link #setLocation}. * updated with {@link #setLocation}.
*/ */
public Sprite () public Sprite ()
{ {
@@ -43,8 +43,8 @@ public class Sprite implements DirectionCodes
/** /**
* Constructs a sprite without any associated frames. The sprite * Constructs a sprite without any associated frames. The sprite
* should be populated with a set of frames used to display it via * should be populated with a set of frames used to display it via a
* a subsequent call to {@link #setFrames}. * subsequent call to {@link #setFrames}.
* *
* @param x the sprite x-position in pixels. * @param x the sprite x-position in pixels.
* @param y the sprite y-position in pixels. * @param y the sprite y-position in pixels.
@@ -213,8 +213,17 @@ public class Sprite implements DirectionCodes
} }
/** /**
* Returns whether the sprite is inside the given shape in * Returns true if the sprite's bounds contain the specified point,
* pixel coordinates. * false if not.
*/
public boolean contains (int x, int y)
{
return _bounds.contains(x, y);
}
/**
* Returns whether the sprite is inside the given shape in pixel
* coordinates.
*/ */
public boolean inside (Shape shape) public boolean inside (Shape shape)
{ {
@@ -293,10 +302,18 @@ public class Sprite implements DirectionCodes
} }
/** /**
* Set the sprite's active path and start moving it along its * Returns true if this sprite is currently following a path, false if
* merry way. If the sprite is already moving along a previous * it is not.
* path the old path will be lost and the new path will begin to */
* be traversed. public boolean isMoving ()
{
return (_path != null);
}
/**
* Set the sprite's active path and start moving it along its merry
* way. If the sprite is already moving along a previous path the old
* path will be lost and the new path will begin to be traversed.
* *
* @param path the path to follow. * @param path the path to follow.
*/ */