java.lang.Objectsprite.Sprite
sprite.SimpleGun
public class SimpleGun
A sprite that represents a gun. The gun can shoot Bullet sprites. The gun is shown as a blue ball with a gun barrel sticking out of it. The barrel points in the direction that bullets will be shot.
Field Summary |
---|
Fields inherited from class sprite.Sprite |
---|
EXIT_POLICY_BOUNCE, EXIT_POLICY_DIE, EXIT_POLICY_STOP, EXIT_POLICY_WRAP |
Constructor Summary | |
---|---|
SimpleGun()
Creates a gun whose barrel initially points up. |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics g)
This method is called by the SpritePanel to tell the sprite to draw itself. |
void |
fire()
Fire a bullet by adding a Bullet sprite to the panel that contains this GunSprite. |
double |
getAngle()
|
double |
getBulletSpeed()
|
void |
setAngle(double degrees)
Sets the direction that the gun is pointing. |
void |
setBulletSpeed(double speed)
Sets the speed for bullets fired by this gun. |
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 SimpleGun()
Method Detail |
---|
public void draw(java.awt.Graphics g)
Sprite
draw
in class Sprite
public void fire()
public double getAngle()
public double getBulletSpeed()
public void setAngle(double degrees)
public void setBulletSpeed(double speed)