|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.Label
public class Label
A text label, with optional word wrapping.
Unlike most scene2d.ui widgets, label can be scaled and rotated using the actor's scale, rotation, and origin. This only affects drawing, other scene2d.ui widgets will still use the unscaled and unrotated bounds of the label. Note that a scaled or rotated label causes a SpriteBatch flush when it is drawn, so should be used relatively sparingly.
The preferred size of the label is determined by the actual text bounds, unless word wrap
is enabled.
Nested Class Summary | |
---|---|
static class |
Label.LabelStyle
The style for a label, see Label . |
Constructor Summary | |
---|---|
Label(java.lang.CharSequence text,
Label.LabelStyle style)
|
|
Label(java.lang.CharSequence text,
Skin skin)
|
|
Label(java.lang.CharSequence text,
Skin skin,
java.lang.String styleName)
|
|
Label(java.lang.CharSequence text,
Skin skin,
java.lang.String fontName,
Color color)
Creates a label, using a Label.LabelStyle that has a BitmapFont with the specified name from the skin and the specified
color. |
|
Label(java.lang.CharSequence text,
Skin skin,
java.lang.String fontName,
java.lang.String colorName)
Creates a label, using a Label.LabelStyle that has a BitmapFont with the specified name and the specified color from the
skin. |
Method Summary | |
---|---|
void |
draw(SpriteBatch batch,
float parentAlpha)
If this method is overridden, the super method or Widget.validate() should be called to ensure the widget is laid out. |
float |
getFontScaleX()
|
float |
getFontScaleY()
|
float |
getPrefHeight()
|
float |
getPrefWidth()
|
Label.LabelStyle |
getStyle()
Returns the label's style. |
java.lang.CharSequence |
getText()
|
BitmapFont.TextBounds |
getTextBounds()
|
void |
invalidate()
Invalidates this actor's layout, causing Layout.layout() to happen the next time Layout.validate() is called. |
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls Layout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child. |
void |
setAlignment(int wrapAlign)
|
void |
setAlignment(int labelAlign,
int lineAlign)
|
void |
setFontScale(float fontScale)
|
void |
setFontScale(float fontScaleX,
float fontScaleY)
|
void |
setFontScaleX(float fontScaleX)
|
void |
setFontScaleY(float fontScaleY)
|
void |
setStyle(Label.LabelStyle style)
|
void |
setText(java.lang.CharSequence newText)
|
void |
setWrap(boolean wrap)
If false, the text will only wrap where it contains newlines (\n). |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
act, addAction, addCaptureListener, addListener, clearActions, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, hit, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setParent, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Label(java.lang.CharSequence text, Skin skin)
public Label(java.lang.CharSequence text, Skin skin, java.lang.String styleName)
public Label(java.lang.CharSequence text, Skin skin, java.lang.String fontName, Color color)
Label.LabelStyle
that has a BitmapFont with the specified name from the skin and the specified
color.
public Label(java.lang.CharSequence text, Skin skin, java.lang.String fontName, java.lang.String colorName)
Label.LabelStyle
that has a BitmapFont with the specified name and the specified color from the
skin.
public Label(java.lang.CharSequence text, Label.LabelStyle style)
Method Detail |
---|
public void setStyle(Label.LabelStyle style)
public Label.LabelStyle getStyle()
setStyle(LabelStyle)
is
called.
public void setText(java.lang.CharSequence newText)
newText
- May be null.public java.lang.CharSequence getText()
public void invalidate()
Layout
Layout.layout()
to happen the next time Layout.validate()
is called. This
method should be called when state changes in the actor that requires a layout but does not change the minimum, preferred,
maximum, or actual size of the actor (meaning it does not affect the parent actor's layout).
invalidate
in interface Layout
invalidate
in class Widget
public void layout()
Layout
Layout.invalidate()
any each child whose width or height has changed, and calls Layout.validate()
on each child.
This method should almost never be called directly, instead Layout.validate()
should be used.
layout
in interface Layout
layout
in class Widget
public void draw(SpriteBatch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.
draw
in class Widget
parentAlpha
- Should be multipied with the actor's alpha, allowing a parent's alpha to affect all children.public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
public BitmapFont.TextBounds getTextBounds()
public void setWrap(boolean wrap)
public void setAlignment(int wrapAlign)
wrapAlign
- Aligns each line of text horizontally and all the text vertically.Align
public void setAlignment(int labelAlign, int lineAlign)
labelAlign
- Aligns all the text with the label widget.lineAlign
- Aligns each line of text (left, right, or center).Align
public void setFontScale(float fontScale)
public void setFontScale(float fontScaleX, float fontScaleY)
public float getFontScaleX()
public void setFontScaleX(float fontScaleX)
public float getFontScaleY()
public void setFontScaleY(float fontScaleY)
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |