java.lang.Objectsprite.Sprite
sprite.TextSprite
public class TextSprite
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 |
---|
public TextSprite(java.lang.String s)
java.lang.IllegalArgumentException
- if s is nullMethod Detail |
---|
public void draw(java.awt.Graphics g)
draw
in class Sprite
public java.awt.Color getColor()
public java.awt.Font getFont()
public java.lang.String getText()
public void setColor(java.awt.Color c)
public void setFont(java.awt.Font f)
public void setText(java.lang.String s)
java.lang.IllegalArgumentException
- if s is null.