sprite
Class Explosion

java.lang.Object
  extended by sprite.Sprite
      extended by sprite.Explosion

public class Explosion
extends Sprite

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

Explosion

public Explosion(double x,
                 double y)
Create an Explosion sprite with lifetime equal to 10 frames and maximum size equal to 30. The location of the explosion is (x,y).


Explosion

public Explosion(double x,
                 double y,
                 int lifeInFrames,
                 int maxSize)
Create an Explosion sprite with specified position, lifetime, and final size.

Method Detail

draw

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.

Overrides:
draw in class Sprite

prepareForNextFrame

public 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.

Overrides:
prepareForNextFrame in class Sprite