Package ecs
Class Text
java.lang.Object
ecs.Text
- Author:
- Asher Haun Represents a renderable string containing a TTF font reference, color data, and font size.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addX
(float x) Add to the existing X position incrementally each time this method is called.void
addY
(float y) Add to the existing Y position incrementally each time this method is called.void
This method is called when the user wants to modify the string in the Text object.float
getX()
float
getY()
boolean
void
Applies a rainbow effect to the Text, gradually changing the color of each Glyph in a rainbow.void
setCentered
(boolean centered) Allows the user to change the text alignment after creation.void
Set the color of the entire Text object.void
setPosition
(org.joml.Vector2f position) Allows the user to change the position of the Text object.void
setX
(float x) void
setY
(float y) void
update()
Update method called for every text object by the scene.Scene.updateUI() method.int
zIndex()
-
Constructor Details
-
Text
public Text(String string, Font font, Color color, float x, float y, int zIndex, boolean isSticky, boolean isCentered) - Parameters:
string
- the text to be rendered.font
- theFont
object that contains your preferred .ttf font file.color
- theColor
object that contains your prefered RGBA color.x
- the X position of the Text object.y
- the Y position of the Text object.zIndex
- the Z-Index of the Text Object (currently can only be set on creation, this will change in the future).isSticky
- boolean determining whether the text sticks in one position regardless of the camera position (isSticky = true) or if it will move in world space.isCentered
- boolean determining whether the text is left aligned or center aligned. This can be changed after creation using .setCentered().
-
Text
-
Text
- Parameters:
string
- the text to be rendered.color
- theColor
object that contains your prefered RGBA color.x
- the X position of the Text object.y
- the Y position of the Text object.
-
Text
- Parameters:
string
- the text to be rendered.x
- the X position of the Text object.y
- the Y position of the Text object.
-
-
Method Details
-
update
public void update()Update method called for every text object by the scene.Scene.updateUI() method. This should not be called by general users. -
change
This method is called when the user wants to modify the string in the Text object. This can be called anytime after object creation.- Parameters:
string
- the text to change the current string to.
-
getGlyphRenderers
-
setColor
Set the color of the entire Text object.- Parameters:
color
- RGBA Color object.
-
rainbowify
public void rainbowify()Applies a rainbow effect to the Text, gradually changing the color of each Glyph in a rainbow. -
isCentered
public boolean isCentered()- Returns:
- boolean value of isCentered.
-
setCentered
public void setCentered(boolean centered) Allows the user to change the text alignment after creation.- Parameters:
centered
- boolean isCentered.
-
zIndex
public int zIndex() -
getX
public float getX() -
getY
public float getY() -
setX
public void setX(float x) -
setY
public void setY(float y) -
setPosition
public void setPosition(org.joml.Vector2f position) Allows the user to change the position of the Text object.- Parameters:
position
- Vector2f containing new position data.
-
addY
public void addY(float y) Add to the existing Y position incrementally each time this method is called.- Parameters:
y
- amount to increment Y position by.
-
addX
public void addX(float x) Add to the existing X position incrementally each time this method is called.- Parameters:
x
- amount to increment X position by.
-