vooga.widget
Class Button

java.lang.Object
  extended by com.golden.gamedev.object.Sprite
      extended by vooga.engine.core.BetterSprite
          extended by vooga.widget.Button
All Implemented Interfaces:
IEventHandler
Direct Known Subclasses:
AboutButton, BuyBlackHoleButton, BuyMissileButton, ConfigButton, GameOverButton, GoButton, LevelButton, NextLevelButton, NextLevelButton, PlayButton, PlayButton, PlayButton, QuitButton, QuitButton, RestartButton, ResumeButton, ShoppingLevelButton, SwitchStateButton, TowerSwitchButton

public abstract class Button
extends BetterSprite
implements IEventHandler

Reusable abstract Button implementation that represents a simple Sprite that allows for some action to be performed upon a mouse click Right now, you must pass each Button an instance of the game it is in, which seems bad. Ultimately we hope to find a way to call the Game methods without a specific instance of game.


Field Summary
protected  java.awt.image.BufferedImage buttonImage
           
protected  Game myGame
          Instance of the game in which the Button exists
 
Constructor Summary
Button()
          Creates an instance of Button with a null image and a location of (0,0)
Button(java.awt.image.BufferedImage image)
          Creates an instance of Button with a specified image and a location of (0,0)
Button(java.awt.image.BufferedImage image, double x, double y)
          Creates an instance of Button with a specified image and location
Button(double x, double y)
          Creates an instance of Button at a specified location with a null image
 
Method Summary
abstract  void actionPerformed()
          Specifies what should be done when the button is clicked
 boolean isTriggered()
          Decides when button has been triggered
 void setSize(int width, int height)
           
 void setText(java.lang.String text)
           
 
Methods inherited from class vooga.engine.core.BetterSprite
addAnimatedImages, addHorizontalSpeed, addImage, addSprite, addVerticalSpeed, firstRun, forceX, forceY, getCurrentSprite, getDistance, getDoubleStat, getHeight, getHorizontalSpeed, getImage, getIntStat, getStat, getTimeInExistence, getVerticalSpeed, getWidth, getX, getY, isActive, isOnScreen, move, moveTo, moveX, moveY, render, setActive, setAsRenderedSprite, setBackground, setDoubleStat, setHorizontalSpeed, setImage, setImages, setIntStat, setLayer, setLocation, setMovement, setSpeed, setStat, setVerticalSpeed, setX, setY, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myGame

protected Game myGame
Instance of the game in which the Button exists


buttonImage

protected java.awt.image.BufferedImage buttonImage
Constructor Detail

Button

public Button()
Creates an instance of Button with a null image and a location of (0,0)


Button

public Button(java.awt.image.BufferedImage image)
Creates an instance of Button with a specified image and a location of (0,0)

Parameters:
image - Which represents the image of the button

Button

public Button(java.awt.image.BufferedImage image,
              double x,
              double y)
Creates an instance of Button with a specified image and location

Parameters:
image - Which represents the image of the button
x - Which represents the X-coordinate of the button
y - Which represents the Y-coordinate of the button

Button

public Button(double x,
              double y)
Creates an instance of Button at a specified location with a null image

Parameters:
x - Which represents the X-coordinate of the button
y - Which represents the Y-coordinate of the button
Method Detail

setSize

public void setSize(int width,
                    int height)

setText

public void setText(java.lang.String text)

isTriggered

public boolean isTriggered()
Decides when button has been triggered

Specified by:
isTriggered in interface IEventHandler
Returns:
whether the button has been triggered

actionPerformed

public abstract void actionPerformed()
Specifies what should be done when the button is clicked

Specified by:
actionPerformed in interface IEventHandler