sprite.sprite2d
Class AnimateImageSprite

java.lang.Object
  extended by sprite.Sprite
      extended by sprite.sprite2d.Sprite2D
          extended by sprite.sprite2d.AnimateImageSprite
All Implemented Interfaces:
java.io.Serializable

public class AnimateImageSprite
extends Sprite2D
implements java.io.Serializable

Created on November 13, 2006, 1:53 PM
A sprite used to display a specified image.
Has the ability to set a sequence of images and loop through them to create animation.

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

Field Summary
 
Fields inherited from class sprite.sprite2d.Sprite2D
fill, spriteColor
 
Fields inherited from class sprite.Sprite
active, visible
 
Constructor Summary
AnimateImageSprite()
          Creates a new instance of AnimateImageSprite
 
Method Summary
 void fillImages()
          Loops through the number of images in the sequence until they are all loaded.
 java.lang.String getBaseImageExt()
          Gets the extension used for the images.
 java.lang.String getBaseImageName()
          Gets the base image name
 java.awt.image.BufferedImage getBufferedImage(java.lang.String imagePath)
          Gets the buffered image.
 int getImageCount()
          Gets the number of images in the array.
 int getImageDirection()
          Gets the direction of animation.
 int getImageOn()
          Get the current image.
 int getStart()
          Gets the starting image number.
 java.awt.image.BufferedImage[] getTheImage()
          Gets the image.
 int getTransparentColor()
          Gets the Color to make transparent.
 boolean isTransparent()
          The backgrounds transparency state.
 void loadImage(java.lang.String imagePath)
          Loads the image.
 java.awt.image.BufferedImage makeTransparent(java.awt.image.BufferedImage bImage, java.awt.image.BufferedImage bImageTemp)
          Makes background transparent.
 void paintSprite(java.awt.Graphics2D g)
          Paints the sprite.
 void setBaseImageExt(java.lang.String baseImageExt)
          Sets the extension to use.
 void setBaseImageName(java.lang.String baseImageName)
          Sets the base image name.
 void setImageCount(int imageCount)
          Sets the number of images in the array.
Used to determine the number of images that need to be loaded.
 void setImageDirection(int imageDirection)
          Sets the direction of animation.
 void setImageOn(int imageOn)
          Sets the current image.
 void setStart(int start)
          Sets the starting image.
 void setTheImage(java.awt.image.BufferedImage[] theImage)
          Sets the image array.
 void setTransparent(boolean transparent)
          Sets the transparency state of the background.
 void setTransparentColor(int transparentColor)
          Sets the color that should be transparent.
 void updateSprite(java.awt.Component c)
          Updates the sprite.
 boolean waitForImage(java.awt.Image image, java.awt.Component c)
          Waits for the image to be loaded.
 
Methods inherited from class sprite.sprite2d.Sprite2D
checkCollision, getHeight, getSpriteColor, getStartX, getStartY, getWidth, getXPosition, getYPosition, isFill, setFill, setHeight, setSpriteColor, setStartX, setStartY, setWidth, setXPosition, setYPosition
 
Methods inherited from class sprite.Sprite
addPropertyChangeListener, getPropertySupport, isActive, isVisible, removePropertyChangeListener, restore, setActive, setVisible, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimateImageSprite

public AnimateImageSprite()
Creates a new instance of AnimateImageSprite

Method Detail

paintSprite

public void paintSprite(java.awt.Graphics2D g)
Paints the sprite.
Paints the image.

Specified by:
paintSprite in class Sprite
Parameters:
g - The graphics to paint with.

updateSprite

public void updateSprite(java.awt.Component c)
Updates the sprite.

Specified by:
updateSprite in class Sprite
Parameters:
c - The owner of the sprite.

loadImage

public void loadImage(java.lang.String imagePath)
Loads the image.

Parameters:
imagePath - The path to load the image from.

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage(java.lang.String imagePath)
Gets the buffered image.

Parameters:
imagePath - The path to load the image from.
Returns:
The loaded image.

makeTransparent

public java.awt.image.BufferedImage makeTransparent(java.awt.image.BufferedImage bImage,
                                                    java.awt.image.BufferedImage bImageTemp)
Makes background transparent.
Uses an absolute color and must be the color in the top left corner (0,0).

Parameters:
bImage - The image to alter.
bImageTemp - The original source image.
Returns:
The altered image.

waitForImage

public boolean waitForImage(java.awt.Image image,
                            java.awt.Component c)
Waits for the image to be loaded.

Parameters:
image - The image being loaded.
c - The component loading the image.
Returns:
The status of the load.

getTheImage

public java.awt.image.BufferedImage[] getTheImage()
Gets the image.

Returns:
The current image to be painted.

setTheImage

public void setTheImage(java.awt.image.BufferedImage[] theImage)
Sets the image array.

Parameters:
theImage - The new image array to be used.

getImageCount

public int getImageCount()
Gets the number of images in the array.

Returns:
The number of images in the array/loop.

setImageCount

public void setImageCount(int imageCount)
Sets the number of images in the array.
Used to determine the number of images that need to be loaded.

Parameters:
imageCount - The total number of images loaded.

getBaseImageName

public java.lang.String getBaseImageName()
Gets the base image name

Returns:
The base image name.

setBaseImageName

public void setBaseImageName(java.lang.String baseImageName)
Sets the base image name.

Parameters:
baseImageName - The new base image name.

getBaseImageExt

public java.lang.String getBaseImageExt()
Gets the extension used for the images.

Returns:
The image extension.

setBaseImageExt

public void setBaseImageExt(java.lang.String baseImageExt)
Sets the extension to use.

Parameters:
baseImageExt - The new extension.

getImageOn

public int getImageOn()
Get the current image.

Returns:
The single current image.

setImageOn

public void setImageOn(int imageOn)
Sets the current image.

Parameters:
imageOn - Index of the image in the array of images.

getImageDirection

public int getImageDirection()
Gets the direction of animation.

Returns:
The direction of animation.

setImageDirection

public void setImageDirection(int imageDirection)
Sets the direction of animation.

Parameters:
imageDirection - The new direction of the animation.

fillImages

public void fillImages()
Loops through the number of images in the sequence until they are all loaded.


getStart

public int getStart()
Gets the starting image number.

Returns:
The start.

setStart

public void setStart(int start)
Sets the starting image.

Parameters:
start - The new start position.

getTransparentColor

public int getTransparentColor()
Gets the Color to make transparent.

Returns:
The color that should be transparent.

setTransparentColor

public void setTransparentColor(int transparentColor)
Sets the color that should be transparent.

Parameters:
transparentColor - The new transparent color.

isTransparent

public boolean isTransparent()
The backgrounds transparency state.

Returns:
True if using transparency, otherwise false.

setTransparent

public void setTransparent(boolean transparent)
Sets the transparency state of the background.

Parameters:
transparent - True if transparent, otherwise false.