|
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.
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 . |
static interface |
Slider.ValueChangedListener
Interface to listen for changes to the value of the slider. |
Field Summary |
---|
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y |
Constructor Summary | |
---|---|
Slider(float min,
float max,
float steps,
Skin skin)
|
|
Slider(float min,
float max,
float steps,
Slider.SliderStyle style)
|
|
Slider(float min,
float max,
float steps,
Slider.SliderStyle style,
java.lang.String name)
Creates a new slider. |
|
Slider(Skin 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 |
getPrefHeight()
|
float |
getPrefWidth()
|
Slider.SliderStyle |
getStyle()
Returns the slider's style. |
float |
getValue()
|
boolean |
isDragging()
Returns true if the slider is being dragged. |
void |
setRange(float min,
float max)
Sets the range of this slider. |
void |
setStyle(Slider.SliderStyle style)
|
void |
setValue(float value)
|
void |
setValueChangedListener(Slider.ValueChangedListener listener)
|
boolean |
touchDown(float x,
float y,
int pointer)
|
void |
touchDragged(float x,
float y,
int pointer)
|
void |
touchUp(float x,
float y,
int pointer)
|
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, hit, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, toScreenCoordinates, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
act, action, clearActions, getStage, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchMoved |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Slider(Skin skin)
public Slider(float min, float max, float steps, Skin skin)
public Slider(float min, float max, float steps, Slider.SliderStyle style)
public Slider(float min, float max, float steps, Slider.SliderStyle style, java.lang.String name)
NinePatch
or slider handle TextureRegion
. The min and max values determine
the range the values of this slider can take on, the steps parameter specifies the distance between individual values. E.g.
min could be 4, max could be 10 and steps 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 valuesteps
- the step size between valuesstyle
- the Slider.SliderStyle
name
- the nameMethod Detail |
---|
public void setStyle(Slider.SliderStyle style)
public Slider.SliderStyle getStyle()
setStyle(SliderStyle)
is
called.
public void draw(SpriteBatch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.
draw
in class Widget
batch
- the spritebatch to render withparentAlpha
- the parent's alpha value.public boolean touchDown(float x, float y, int pointer)
touchDown
in class Widget
public void touchUp(float x, float y, int pointer)
touchUp
in class Widget
public void touchDragged(float x, float y, int pointer)
touchDragged
in class Widget
public boolean isDragging()
public void setValueChangedListener(Slider.ValueChangedListener listener)
listener
- May be null.public float getValue()
public void setValue(float value)
public void setRange(float min, float max)
public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |