sprite
Class TextSprite

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

public class TextSprite
extends Sprite

A sprite that displays a string of text. The position of the sprite is the center of the string.


Field Summary
 
Fields inherited from class sprite.Sprite
EXIT_POLICY_BOUNCE, EXIT_POLICY_DIE, EXIT_POLICY_STOP, EXIT_POLICY_WRAP
 
Constructor Summary
TextSprite(java.lang.String s)
          Create a text sprite to display given text.
 
Method Summary
 void draw(java.awt.Graphics g)
          Draw the text, centered on the (x,y)-position of the sprite.
 java.awt.Color getColor()
           
 java.awt.Font getFont()
           
 java.lang.String getText()
           
 void setColor(java.awt.Color c)
          Sets the color of this Sprite.
 void setFont(java.awt.Font f)
          Changes the font to be used for drawing the text.
 void setText(java.lang.String s)
          Changes the text that is displayed by this Sprite.
 
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

TextSprite

public TextSprite(java.lang.String s)
Create a text sprite to display given text. Note that the width and height of the sprite will be computed automatically, based on the font and the text.

Throws:
java.lang.IllegalArgumentException - if s is null
Method Detail

draw

public void draw(java.awt.Graphics g)
Draw the text, centered on the (x,y)-position of the sprite.

Overrides:
draw in class Sprite

getColor

public java.awt.Color getColor()

getFont

public java.awt.Font getFont()

getText

public java.lang.String getText()

setColor

public void setColor(java.awt.Color c)
Sets the color of this Sprite. If the specified color is null, the default color, black, is used.


setFont

public void setFont(java.awt.Font f)
Changes the font to be used for drawing the text.


setText

public void setText(java.lang.String s)
Changes the text that is displayed by this Sprite.

Throws:
java.lang.IllegalArgumentException - if s is null.