Class ImageSprite

  extended by sprite.Sprite
      extended by sprite.ImageSprite

public class ImageSprite
extends Sprite

A sprite that displays an image. The position of the sprite gives the center of the image.

Field Summary
Fields inherited from class sprite.Sprite
Constructor Summary
ImageSprite(java.lang.String imageResource)
          Create an ImageSprite to display a given image.
ImageSprite(java.lang.String imageResource, boolean isOval)
Method Summary
 void draw(java.awt.Graphics g)
          This method is called by the SpritePanel to tell the sprite to draw itself.
Methods inherited from class sprite.Sprite
contains, die, getDx, getDy, getExitPolicy, getHome, getSpriteHeight, getSpriteWidth, getX, getY, isDead, isImmuneToBullets, onDeath, prepareForNextFrame, randomVelocity, setDx, setDy, setExitPolicy, setImmuneToBullets, setLocation, setSpriteHeight, setSpriteWidth, setUseOvalForContains, setVelocity, setX, setY
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ImageSprite(java.lang.String imageResource)
Create an ImageSprite to display a given image. The width and height of the sprite are set to match the width and height of the image, and they should not be changed.

imageResource - give the name of the image file. The image file must be part of the program. If the file is in a folder, then the folder name must be part of the image name. For example: "images/earth.png". PNG and JPEG images, at least, are supported (with file extensions .png, .jpg, .jpeg).


public ImageSprite(java.lang.String imageResource,
                   boolean isOval)
Method Detail


public void draw(java.awt.Graphics g)
Description copied from class: Sprite
This method is called by the SpritePanel to tell the sprite to draw itself. It is not meant to be called directly. Subclasses should override this method to draw an appropriate picture. The method in this class just draws a tiny black dot at the location of the sprite.

draw in class Sprite