java.lang.Objectsprite.Sprite
sprite.ImageSprite
public class ImageSprite
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 |
---|
EXIT_POLICY_BOUNCE, EXIT_POLICY_DIE, EXIT_POLICY_STOP, EXIT_POLICY_WRAP |
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)
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)
Sprite
draw
in class Sprite