java.lang.Objectsprite.Sprite
sprite.Explosion
public class Explosion
A sprite that represents an explosion. It has a limited lifetime and a maximum size. Over the course of its lifetime, it grows from 1/3 of the maximum size to the maximum size. Once its lifetime is over, it dies automatically and is removed from the SpritePanel. The lifetime and final size are determined when the Explosion is constructed and cannot be changed.
Field Summary |
---|
Fields inherited from class sprite.Sprite |
---|
EXIT_POLICY_BOUNCE, EXIT_POLICY_DIE, EXIT_POLICY_STOP, EXIT_POLICY_WRAP |
Constructor Summary | |
---|---|
Explosion(double x,
double y)
Create an Explosion sprite with lifetime equal to 10 frames and maximum size equal to 30. |
|
Explosion(double x,
double y,
int lifeInFrames,
int maxSize)
Create an Explosion sprite with specified position, lifetime, and final size. |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics g)
This method is called by the SpritePanel to tell the sprite to draw itself. |
void |
prepareForNextFrame(int frameNumber)
Note: This method is called by the SpritePanel that contains the explosion to get the sprite ready for the next frame, and is not meant to be called for other reasons; it kills the sprite when the age of the sprite exceeds its lifetime. |
Methods inherited from class sprite.Sprite |
---|
contains, die, getDx, getDy, getExitPolicy, getHome, getSpriteHeight, getSpriteWidth, getX, getY, isDead, isImmuneToBullets, onDeath, 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 Explosion(double x, double y)
public Explosion(double x, double y, int lifeInFrames, int maxSize)
Method Detail |
---|
public void draw(java.awt.Graphics g)
Sprite
draw
in class Sprite
public void prepareForNextFrame(int frameNumber)
prepareForNextFrame
in class Sprite