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
Nested ClassesModifier and TypeClassDescriptionstatic enumThis 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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the size of the font of thisTextBasedEntityin px.intReturns the maximum width of thisTextBasedEntityin pixels, before it gets ellipsed.getText()Returns the string thisTextBasedEntitydisplays.Returns text alignment of thisTextBasedEntity.setFontSize(int fontSize) Sets the size of the font of thisTextBasedEntityin px.setFontSize(int fontSize, Curve curve) Sets the size of the font of thisTextBasedEntityin px.setMaxWidth(int maxWidth) Sets the maximum width of thisTextBasedEntityin pixels before it gets ellipsed.Sets the string for thisTextBasedEntityto 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, setTintMethods inherited from class com.codingame.gameengine.module.entities.BlendableEntity
getBlendMode, setBlendModeMethods 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 thisTextBasedEntitydisplays.Default is "" (empty string).
- Returns:
- the string of this
TextBasedEntity.
-
setText
Sets the string for thisTextBasedEntityto display.Default is "" (empty string).
- Parameters:
text- the string for thisTextBasedEntityto 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 thisTextBasedEntityin px.Default is 26.
- Returns:
- the size of the font of this
TextBasedEntity.
-
setFontSize
Sets the size of the font of thisTextBasedEntityin px.Default is 26.
- Parameters:
fontSize- the size for the font of thisTextBasedEntity.- Returns:
- this
Text.
-
setFontSize
Sets the size of the font of thisTextBasedEntityin 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 thisTextBasedEntityin 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 thisTextBasedEntityin 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.
-