Class TextBasedEntity<T extends TextureBasedEntity<?>>
java.lang.Object
com.codingame.gameengine.module.entities.Entity<T>
com.codingame.gameengine.module.entities.BlendableEntity<T>
com.codingame.gameengine.module.entities.TextureBasedEntity<T>
com.codingame.gameengine.module.entities.TextBasedEntity<T>
- Type Parameters:
T
- a subclass inheriting TextureBasedEntity, used in order to return this as a T instead of aTextBasedEntity
.
- Direct Known Subclasses:
BitmapText
,Text
public abstract class TextBasedEntity<T extends TextureBasedEntity<?>>
extends TextureBasedEntity<T>
Generic type for entities containing text.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
This is an enumeration that contains the three options for text alignment: left, center, and right.Nested classes/interfaces inherited from class com.codingame.gameengine.module.entities.BlendableEntity
BlendableEntity.BlendMode
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the size of the font of thisTextBasedEntity
in px.int
Returns the maximum width of thisTextBasedEntity
in pixels, before it gets ellipsed.getText()
Returns the string thisTextBasedEntity
displays.Returns text alignment of thisTextBasedEntity
.setFontSize
(int fontSize) Sets the size of the font of thisTextBasedEntity
in px.setFontSize
(int fontSize, Curve curve) Sets the size of the font of thisTextBasedEntity
in px.setMaxWidth
(int maxWidth) Sets the maximum width of thisTextBasedEntity
in pixels before it gets ellipsed.Sets the string for thisTextBasedEntity
to display.Sets the text alignment of thisTextBasedEntity
.Methods inherited from class com.codingame.gameengine.module.entities.TextureBasedEntity
getAnchorX, getAnchorY, getTint, setAnchor, setAnchorX, setAnchorX, setAnchorY, setAnchorY, setTint, setTint
Methods inherited from class com.codingame.gameengine.module.entities.BlendableEntity
getBlendMode, setBlendMode
Methods inherited from class com.codingame.gameengine.module.entities.Entity
getAlpha, getId, getMask, getParent, getRotation, getScaleX, getScaleY, getSkewX, getSkewY, getX, getY, getZIndex, isVisible, requireValidAlpha, requireValidColor, self, set, set, setAlpha, setAlpha, setMask, setMask, setRotation, setRotation, setScale, setScale, setScaleX, setScaleX, setScaleY, setScaleY, setSkewX, setSkewX, setSkewY, setSkewY, setVisible, setX, setX, setY, setY, setZIndex
-
Field Details
-
text
-
fontSize
protected int fontSize -
maxWidth
protected int maxWidth -
textAlign
-
-
Constructor Details
-
TextBasedEntity
public TextBasedEntity()
-
-
Method Details
-
getText
Returns the string thisTextBasedEntity
displays.Default is "" (empty string).
- Returns:
- the string of this
TextBasedEntity
.
-
setText
Sets the string for thisTextBasedEntity
to display.Default is "" (empty string).
- Parameters:
text
- the string for thisTextBasedEntity
to display.- Returns:
- this
Text
. - Throws:
NullPointerException
- if text is null.
-
getTextAlign
Returns text alignment of thisTextBasedEntity
.Default is TextAlign.LEFT (align left).
- Returns:
- the text alignment of this
TextBasedEntity
.
-
setTextAlign
Sets the text alignment of thisTextBasedEntity
.Default is TextAlign.LEFT (align left).
- Parameters:
align
- the text alignment of thisTextBasedEntity
.- Returns:
- this
Text
. - Throws:
NullPointerException
- if align is null.
-
getFontSize
public int getFontSize()Returns the size of the font of thisTextBasedEntity
in px.Default is 26.
- Returns:
- the size of the font of this
TextBasedEntity
.
-
setFontSize
Sets the size of the font of thisTextBasedEntity
in px.Default is 26.
- Parameters:
fontSize
- the size for the font of thisTextBasedEntity
.- Returns:
- this
Text
.
-
setFontSize
Sets the size of the font of thisTextBasedEntity
in px.Default is 26.
- Parameters:
fontSize
- the size for the font of thisTextBasedEntity
.curve
- the transition to animate between values of this property.- Returns:
- this
Text
.
-
getMaxWidth
public int getMaxWidth()Returns the maximum width of thisTextBasedEntity
in pixels, before it gets ellipsed.The ellipsis is applied before the entity is scaled. A max width of 0 means there is no maximum width.
Default is 0 (no max width).
- Returns:
- the maximum width in pixels of this
TextBasedEntity
.
-
setMaxWidth
Sets the maximum width of thisTextBasedEntity
in pixels before it gets ellipsed.The ellipsis is applied before the entity is scaled. A max width of 0 means there is no maximum width.
Default is 0 (no max width).
- Parameters:
maxWidth
- the maximum width in pixels of thisTextBasedEntity
.- Returns:
- this
Text
.
-