cage.graphics
Class Sprite

java.lang.Object
  extended by cage.graphics.Clickable
      extended by cage.graphics.Sprite

public class Sprite
extends Clickable

TODO: Sprite needs a way to set the Image!.

Author:
Seth Marinello

Field Summary
protected  boolean animated
          Is the sprite animated.
protected  java.util.LinkedList<HotSpot> hotSpots
          The hot spots.
protected  VisualItem image
          The image.
protected  boolean visible
          Is the sprite visible.
 
Fields inherited from class cage.graphics.Clickable
actionName, botRight, height, name, topLeft, width
 
Constructor Summary
Sprite(java.lang.String imageName, java.lang.String inName, Point location)
          Instantiates a new Sprite.
 
Method Summary
 void addHotSpot(HotSpot s)
          Adds the hot spot.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getActionName()
          Gets the action name.
 boolean getAnimated()
          Checks if is animated.
 org.minueto.image.MinuetoImage getFrame()
          Gets the frame in the animation.
 HotSpot getHotSpot(java.lang.String name)
          Gets the hot spot.
 java.util.LinkedList<HotSpot> getHotSpots()
          Gets the hot spots.
 org.minueto.image.MinuetoImage getImage()
          Gets the image.
 boolean getLoop()
          Gets loop.
 boolean getPlay()
          Gets play.
 boolean getVisible()
          Checks if the Sprite is visible.
 VisualItem getVisualItem()
          Gets the visual item.
 void scale(double xScale, double yScale)
          Scale the Sprite location and image by the given X and Y scales, as ratios.
 void setActionName(java.lang.String actionName)
          Sets the action name.
 void setLocation(int x, int y)
          Set the location of this sprite to the specified point.
 void setLocation(Point coord)
          Set the location of this sprite to the specified point.
 void setLoop(boolean loop)
          Sets loop.
 void setPlay(boolean play)
          Sets play.
 void setVisible(boolean b)
          Sets if the Sprite is visible.
 java.lang.String toString()
           
 java.lang.String toXML()
          Creates an XML String representing this Sprite
 
Methods inherited from class cage.graphics.Clickable
getLocation, getName, getX, getY, inputCollision, performAction
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

image

protected VisualItem image
The image.


visible

protected boolean visible
Is the sprite visible.


hotSpots

protected java.util.LinkedList<HotSpot> hotSpots
The hot spots.


animated

protected boolean animated
Is the sprite animated.

Constructor Detail

Sprite

public Sprite(java.lang.String imageName,
              java.lang.String inName,
              Point location)
Instantiates a new Sprite.

Parameters:
imageName - the image name
inName - the in name
location - the X,Y location of the upper left of the Sprite.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAnimated

public boolean getAnimated()
Checks if is animated.

Returns:
true, if is animated

getLoop

public boolean getLoop()
Gets loop.

Returns:
loop

setLoop

public void setLoop(boolean loop)
Sets loop.

Parameters:
loop - new loop value

getPlay

public boolean getPlay()
Gets play.

Returns:
play

setPlay

public void setPlay(boolean play)
Sets play.

Parameters:
play - new play

getFrame

public org.minueto.image.MinuetoImage getFrame()
Gets the frame in the animation.

Returns:
the frame

getVisualItem

public VisualItem getVisualItem()
Gets the visual item.

Returns:
the visual item

getImage

public org.minueto.image.MinuetoImage getImage()
Gets the image.

Returns:
the image

setLocation

public void setLocation(Point coord)
Set the location of this sprite to the specified point. Also shifts all of the hot spots on the sprite to match the new location.

Overrides:
setLocation in class Clickable
Parameters:
coord - the X,Y location of the sprite

setLocation

public void setLocation(int x,
                        int y)
Set the location of this sprite to the specified point. Also shifts all of the hot spots on the sprite to match the new location.

Overrides:
setLocation in class Clickable
Parameters:
x - the x coord
y - the y coord

getActionName

public java.lang.String getActionName()
Gets the action name.

Returns:
the action name

setActionName

public void setActionName(java.lang.String actionName)
Sets the action name.

Parameters:
actionName - the new action name

scale

public void scale(double xScale,
                  double yScale)
Scale the Sprite location and image by the given X and Y scales, as ratios.

Parameters:
xScale - the x scale
yScale - the y scale

setVisible

public void setVisible(boolean b)
Sets if the Sprite is visible.

Parameters:
b - the new visible value

getVisible

public boolean getVisible()
Checks if the Sprite is visible.

Returns:
true, if is visible

getHotSpots

public java.util.LinkedList<HotSpot> getHotSpots()
Gets the hot spots.

Returns:
the hot spots

addHotSpot

public void addHotSpot(HotSpot s)
Adds the hot spot.

Parameters:
s - the HotSpot to add.

toXML

public java.lang.String toXML()
Creates an XML String representing this Sprite

Returns:
XML representation of this Sprite object.

getHotSpot

public HotSpot getHotSpot(java.lang.String name)
Gets the hot spot.

Parameters:
name - the name
Returns:
the hot spot