Modified sprite event mechanism to used classes derived from SpriteEvent

rather than codes to indicate different types of events. Also modified
name of sprite observer callback as spriteChanged() implies that the
sprite actually changed which it may not have, whereas handleEvent()
doesn't imply anything other than the sprite observer is being asked to
deal with a sprite event.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@338 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-09-13 19:36:20 +00:00
parent 780e39d4e9
commit 00fde3eeb3
6 changed files with 88 additions and 71 deletions
@@ -1,11 +1,11 @@
//
// $Id: SpriteEvent.java,v 1.1 2001/09/07 23:01:53 shaper Exp $
// $Id: SpriteEvent.java,v 1.2 2001/09/13 19:36:20 mdb Exp $
package com.threerings.media.sprite;
/**
* A sprite event is sent to all sprite observers for a sprite
* whenever one of the various possible sprite events takes place.
* A sprite event is sent to all of a sprite's observers whenever one of
* the various possible sprite events takes place.
*/
public class SpriteEvent
{
@@ -13,65 +13,20 @@ public class SpriteEvent
* Create a sprite event.
*
* @param sprite the involved sprite.
* @param eventCode the event code.
* @param arg the event argument.
*/
public SpriteEvent (Sprite sprite, int eventCode, Object arg)
public SpriteEvent (Sprite sprite)
{
_sprite = sprite;
_eventCode = eventCode;
_arg = arg;
}
/**
* Return the sprite involved in the event.
* Returns the sprite involved in the event.
*/
public Sprite getSprite ()
{
return _sprite;
}
/**
* Return the event code for the event.
*/
public int getEventCode ()
{
return _eventCode;
}
/**
* Return the argument associated with the event.
*/
public Object getArgument ()
{
return _arg;
}
/**
* Event code noting that the sprite completed a path node. The
* argument to the event is the {@link PathNode} completed.
*/
public static final int FINISHED_PATH_NODE = 0;
/**
* Event code noting that the sprite completed its entire path.
* The argument to the event is the {@link Path} completed.
*/
public static final int FINISHED_PATH = 1;
/**
* Event code noting that the sprite collided with another
* sprite. The argument to the event is the {@link Sprite} the
* observed sprite collided with.
*/
public static final int COLLIDED_SPRITE = 2;
/** The sprite associated with this event. */
protected Sprite _sprite;
/** The event code. */
protected int _eventCode;
/** The argument associated with this event. */
protected Object _arg;
}