Package gameobjects
Class TextObject
java.lang.Object
gameobjects.GameObject
gameobjects.TextObject
Convenience Class subclassing
GameObject
, directly instanciating TextArtist
a
subclass of Artist
that draws a text. The controller is left undefined, the collider as
well. However, a single call to the overwritten method generateColliders()
will in fact
generate a RectCollider
of just the right size for the text.-
Field Summary
-
Constructor Summary
ConstructorDescriptionTextObject
(String id, Playground playground, double x, double y, double vx, double vy, String text, int size, Color textColor) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongenerates and sets collider(s) for this GameObject.getText()
void
Methods inherited from class gameobjects.GameObject
addArtist, addCollider, addController, collisionDetection, draw, getGameTime, getId, getObjectController, getObjectFlag, getOrCreateObjectFlag, getPlayground, getVX, getVY, getX, getY, isActive, setActive, setColliders, setComponentProperty, setObjectController, setObjectFlag, setPlayground, setVX, setVY, setX, setY, updateObject
-
Constructor Details
-
TextObject
public TextObject(String id, Playground playground, double x, double y, double vx, double vy, String text, int size, Color textColor) Constructor.- Parameters:
id
- object nameplayground
- containingPlayground
instancex
- positionxy
- positionyvx
- speedxvy
- speedysize
- font size in Pixeltext
- String to be displayedtextColor
- text color, see java.awt.Color
-
-
Method Details
-
getText
-
setText
-
generateColliders
Description copied from class:GameObject
generates and sets collider(s) for this GameObject. This implementation does nothing. Intended to be overridden by subclasses.- Overrides:
generateColliders
in classGameObject
- Returns:
- instance of this GameObject (this).
-