|
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.Slider
public class Slider
A slider is a horizontal indicator that allows a user to set a value. The slider his a range (min, max) and a stepping between each value the slider represents.
ChangeListener.ChangeEvent
is fired when the slider knob is moved. Cancelling the event will move the knob to where it was previously.
The preferred height of a slider is determined by the larger of the knob and background. The preferred width of a slider is 140, a relatively arbitrary size.
Nested Class Summary | |
---|---|
static class |
Slider.SliderStyle
The style for a slider, see Slider . |
Constructor Summary | |
---|---|
Slider(float min,
float max,
float stepSize,
boolean vertical,
Skin skin)
|
|
Slider(float min,
float max,
float stepSize,
boolean vertical,
Skin skin,
java.lang.String styleName)
|
|
Slider(float min,
float max,
float stepSize,
boolean vertical,
Slider.SliderStyle style)
Creates a new slider. |
Method Summary | |
---|---|
void |
act(float delta)
Updates the actor based on time. |
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 |
getMaxValue()
|
float |
getMinValue()
|
float |
getPrefHeight()
|
float |
getPrefWidth()
|
float |
getStepSize()
|
Slider.SliderStyle |
getStyle()
Returns the slider's style. |
float |
getValue()
|
float |
getVisualValue()
If animating the slider value, this returns the value current displayed. |
boolean |
isDragging()
Returns true if the slider is being dragged. |
void |
setAnimateDuration(float duration)
If > 0, changes to the slider value via setValue(float) will happen over this duration in seconds. |
void |
setAnimateInterpolation(Interpolation animateInterpolation)
Sets the interpolation to use for setAnimateDuration(float) . |
void |
setRange(float min,
float max)
Sets the range of this slider. |
void |
setStepSize(float stepSize)
Sets the step size of the slider |
void |
setStyle(Slider.SliderStyle style)
|
void |
setValue(float value)
Sets the slider position, rounded to the nearest step size and clamped to the minumum and maximim values. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
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 Slider(float min, float max, float stepSize, boolean vertical, Skin skin)
public Slider(float min, float max, float stepSize, boolean vertical, Skin skin, java.lang.String styleName)
public Slider(float min, float max, float stepSize, boolean vertical, Slider.SliderStyle style)
NinePatch
or slider handle TextureRegion
. The min and max values determine
the range the values of this slider can take on, the stepSize parameter specifies the distance between individual values.
E.g. min could be 4, max could be 10 and stepSize could be 0.2, giving you a total of 30 values, 4.0 4.2, 4.4 and so on.
min
- the minimum valuemax
- the maximum valuestepSize
- the step size between valuesstyle
- the Slider.SliderStyle
Method Detail |
---|
public void setStyle(Slider.SliderStyle style)
public Slider.SliderStyle getStyle()
setStyle(SliderStyle)
is
called.
public void act(float delta)
Actor
Stage.act(float)
.
The default implementation calls Action.act(float)
on each action and removes actions that are complete.
act
in class Actor
delta
- Time in seconds since the last frame.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 boolean isDragging()
public float getValue()
public float getVisualValue()
animating
the slider value, this returns the value current displayed.
public void setValue(float value)
public void setRange(float min, float max)
public void setStepSize(float stepSize)
public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
public float getMinValue()
public float getMaxValue()
public float getStepSize()
public void setAnimateDuration(float duration)
setValue(float)
will happen over this duration in seconds.
public void setAnimateInterpolation(Interpolation animateInterpolation)
setAnimateDuration(float)
.
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |