sprite.sprite2d
Class Sprite2D

java.lang.Object
  extended by sprite.Sprite
      extended by sprite.sprite2d.Sprite2D
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
OvalSprite

public abstract class Sprite2D
extends Sprite
implements java.io.Serializable

Last updated September 23, 2006.
Extends Sprite. This is the base 2d bean class to be used for all 2d sprites.
Added startX and startY to store the starting x and y positions. These can be used for a reference distance moved.
Added check collision, checks to see if the given point falls within range of the sprite.

Version:
m.5
Author:
Eric Angeli
See Also:
Serialized Form

Field Summary
protected  boolean fill
          The fill state of the sprite.
protected  java.awt.Color spriteColor
          The color of the sprite.
 
Fields inherited from class sprite.Sprite
active, visible
 
Constructor Summary
Sprite2D()
          Creates a new Sprite2D().
 
Method Summary
 boolean checkCollision(int xp, int yp)
          Checks for a collision.
 int getHeight()
          Gets the height of the sprite.
 java.awt.Color getSpriteColor()
          Gets the color of the sprite.
 double getStartX()
          Gets the starting x position.
 double getStartY()
          Gets the starting y position.
 int getWidth()
          Gets the width of the sprite.
 double getXPosition()
          Gets the x position.
 double getYPosition()
          Gets the y position.
 boolean isFill()
          The fill state of the sprite.
 void setFill(boolean fill)
          Sets the fill state of the sprite.
 void setHeight(int height)
          Sets the height of the sprite.
 void setSpriteColor(java.awt.Color spriteColor)
          Sets the sprite's color.
 void setStartX(double startX)
          Sets the starting x position.
 void setStartY(double startY)
          Sets that starting y position.
 void setWidth(int width)
          Sets the width of the sprite.
 void setXPosition(double xPosition)
          Sets the x position.
 void setYPosition(double yPosition)
          Sets the y position.
 
Methods inherited from class sprite.Sprite
addPropertyChangeListener, getPropertySupport, isActive, isVisible, paintSprite, removePropertyChangeListener, restore, setActive, setVisible, suspend, updateSprite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spriteColor

protected java.awt.Color spriteColor
The color of the sprite.


fill

protected boolean fill
The fill state of the sprite.

Constructor Detail

Sprite2D

public Sprite2D()
Creates a new Sprite2D().

Method Detail

getXPosition

public double getXPosition()
Gets the x position.

Returns:
The x position.

setXPosition

public void setXPosition(double xPosition)
Sets the x position.
Fires a property change event.

Parameters:
xPosition - The new xPosition.

getYPosition

public double getYPosition()
Gets the y position.

Returns:
The y position.

setYPosition

public void setYPosition(double yPosition)
Sets the y position.
Fires a property change event.

Parameters:
yPosition - The new y position.

getWidth

public int getWidth()
Gets the width of the sprite.

Returns:
The width.

setWidth

public void setWidth(int width)
Sets the width of the sprite.

Parameters:
width - The new width.

getHeight

public int getHeight()
Gets the height of the sprite.

Returns:
The height.

setHeight

public void setHeight(int height)
Sets the height of the sprite.

Parameters:
height - The new height.

getSpriteColor

public java.awt.Color getSpriteColor()
Gets the color of the sprite.

Returns:
The color.

setSpriteColor

public void setSpriteColor(java.awt.Color spriteColor)
Sets the sprite's color.

Parameters:
spriteColor - The new color.

isFill

public boolean isFill()
The fill state of the sprite.
True is filled, false is unfilled.

Returns:
The fill state.

setFill

public void setFill(boolean fill)
Sets the fill state of the sprite.
True is filled, false is unfilled.

Parameters:
fill - The new fill state.

getStartX

public double getStartX()
Gets the starting x position.

Returns:
The starting x position.

setStartX

public void setStartX(double startX)
Sets the starting x position.

Parameters:
startX - The new starting x position.

getStartY

public double getStartY()
Gets the starting y position.

Returns:
The starting y position.

setStartY

public void setStartY(double startY)
Sets that starting y position.

Parameters:
startY - The new starting y position.

checkCollision

public boolean checkCollision(int xp,
                              int yp)
Checks for a collision.
Uses the points passed in and checks to see if it falls within a range close enough to the Sprite to say there was a collision.

Parameters:
xp - The x position of a possible collision.
yp - The y position of a possible collision.
Returns:
True if there was a collision, false if not.