ch.aplu.jgamegrid
Class TextActor

java.lang.Object
  extended by ch.aplu.jgamegrid.Actor
      extended by ch.aplu.jgamegrid.TextActor
All Implemented Interfaces:
GGActorCollisionListener, GGBorderListener, GGTileCollisionListener, java.util.EventListener

public class TextActor
extends Actor

Class that implements an actor to display text dynamically. This may be a better choice than displaying text as a sprite image, when the text changes at run-time in many different ways.


Field Summary
 
Fields inherited from class ch.aplu.jgamegrid.Actor
gameGrid, nbCycles
 
Constructor Summary
TextActor(boolean isRotatable, java.lang.String text, java.awt.Color textColor, java.awt.Color bgColor, java.awt.Font font)
          Constructs a possibly rotatable text actor that displays the given text with given text and background colors.
TextActor(java.lang.String text)
          Constructs a unrotatable text actor that displays the given text.
TextActor(java.lang.String text, java.awt.Color textColor, java.awt.Color bgColor, java.awt.Font font)
          Constructs a unrotatable text actor that displays the given text with given text and background colors.
 
Method Summary
 int getTextHeight()
          Returns the height of the text.
 int getTextWidth()
          Returns the total width of the text.
 
Methods inherited from class ch.aplu.jgamegrid.Actor
act, addActorCollisionListener, addBorderListener, addCollisionActor, addCollisionActors, addCollisionActors, addCollisionTile, addCollisionTiles, addCollisionTiles, addMouseTouchListener, addMouseTouchListener, addTileCollisionListener, collide, collide, delay, displace, getBackground, getCollisionActors, getCollisionActorsInRange, getCollisionTiles, getCurrentImage, getDirection, getDirectionStart, getDisplacePosition, getHeight, getIdVisible, getImage, getImage, getIntDirection, getLocation, getLocationOffset, getLocationStart, getNbCycles, getNbHorzCells, getNbSprites, getNbVertCells, getNeighbours, getNeighbours, getNextMoveLocation, getPixelColor, getPixelLocation, getRotatedPosition, getRotationIndex, getScaledImage, getScaledImage, getScaledImage, getSlowDown, getWidth, getX, getXStart, getY, getYStart, hide, isActEnabled, isActorCollisionEnabled, isHorzMirror, isInGrid, isMoveValid, isNearBorder, isRemoved, isRotatable, isTileCollisionEnabled, isVertMirror, isVisible, move, move, nearBorder, removeSelf, reset, rotate, rotate, setActEnabled, setActorCollisionEnabled, setCollisionCircle, setCollisionCircle, setCollisionImage, setCollisionImage, setCollisionLine, setCollisionLine, setCollisionRectangle, setCollisionRectangle, setCollisionSpot, setCollisionSpot, setDirection, setDirection, setDisplacePosition, setHorzMirror, setLocation, setLocationOffset, setLocationOffset, setMouseTouchCircle, setMouseTouchCircle, setMouseTouchEnabled, setMouseTouchImage, setMouseTouchImage, setMouseTouchRectangle, setMouseTouchRectangle, setOnBottom, setOnTop, setPixelLocation, setSlowDown, setTileCollisionEnabled, setVertMirror, setX, setY, show, show, showNextSprite, showPreviousSprite, turn
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextActor

public TextActor(boolean isRotatable,
                 java.lang.String text,
                 java.awt.Color textColor,
                 java.awt.Color bgColor,
                 java.awt.Font font)
Constructs a possibly rotatable text actor that displays the given text with given text and background colors. For transparent background use sRGB color with alpha = 0. The text is horizontally left aligned, vertically center aligned.

Parameters:
isRotatable - if true, the text changes the direction corresponding to the actor's direction
text - the text to display, if null or has length 0, the text actor is completely transparent
textColor - the color of the text
bgColor - the background color of the text field
font - the font used to display the text

TextActor

public TextActor(java.lang.String text,
                 java.awt.Color textColor,
                 java.awt.Color bgColor,
                 java.awt.Font font)
Constructs a unrotatable text actor that displays the given text with given text and background colors. For transparent background use sRGB color with alpha = 0. The text is horizontally left aligned, vertically center aligned.

Parameters:
text - the text to display, if null or has length 0, the text actor is completely transparent
textColor - the color of the text
bgColor - the background color of the text field
font - the font used to display the text

TextActor

public TextActor(java.lang.String text)
Constructs a unrotatable text actor that displays the given text. The text color is black, the background color white/transparent ARGB = (255, 255,255, 0) and the font SansSerif, PLAIN, 8 pixels. The text is horizontally left aligned, vertically center aligned.

Parameters:
text - the text to display, if null or has length 0, the text actor is completely transparent
Method Detail

getTextWidth

public int getTextWidth()
Returns the total width of the text. Maybe used to align the text by calling setLocationOffset(),

Returns:
the text width in pixels
See Also:
Actor.setLocationOffset(Point pt)

getTextHeight

public int getTextHeight()
Returns the height of the text. Maybe used to align the text by calling setLocationOffset(),

Returns:
the text height in pixels
See Also:
Actor.setLocationOffset(Point pt)