public class Touchpad extends Widget
The preferred size of the touchpad is determined by the background.
ChangeListener.ChangeEvent
is fired when the touchpad knob is moved. Cancelling the event will move the knob to where it was
previously.
Modifier and Type | Class and Description |
---|---|
static class |
Touchpad.TouchpadStyle
The style for a
Touchpad . |
Constructor and Description |
---|
Touchpad(float deadzoneRadius,
Skin skin) |
Touchpad(float deadzoneRadius,
Skin skin,
String styleName) |
Touchpad(float deadzoneRadius,
Touchpad.TouchpadStyle style) |
Modifier and Type | Method and Description |
---|---|
void |
draw(Batch 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 |
getKnobPercentX()
Returns the x-position of the knob as a percentage from the center of the touchpad to the edge of the circular movement
area.
|
float |
getKnobPercentY()
Returns the y-position of the knob as a percentage from the center of the touchpad to the edge of the circular movement
area.
|
float |
getKnobX()
Returns the x-position of the knob relative to the center of the widget.
|
float |
getKnobY()
Returns the y-position of the knob relative to the center of the widget.
|
float |
getPrefHeight() |
float |
getPrefWidth() |
boolean |
getResetOnTouchUp() |
Touchpad.TouchpadStyle |
getStyle()
Returns the touchpad's style.
|
Actor |
hit(float x,
float y,
boolean touchable)
|
boolean |
isTouched() |
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 |
setDeadzone(float deadzoneRadius) |
void |
setResetOnTouchUp(boolean reset) |
void |
setStyle(Touchpad.TouchpadStyle style) |
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
act, addAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, fire, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasParent, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString
public Touchpad(float deadzoneRadius, Skin skin)
deadzoneRadius
- The distance in pixels from the center of the touchpad required for the knob to be moved.public Touchpad(float deadzoneRadius, Skin skin, String styleName)
deadzoneRadius
- The distance in pixels from the center of the touchpad required for the knob to be moved.public Touchpad(float deadzoneRadius, Touchpad.TouchpadStyle style)
deadzoneRadius
- The distance in pixels from the center of the touchpad required for the knob to be moved.public void setStyle(Touchpad.TouchpadStyle style)
public Touchpad.TouchpadStyle getStyle()
setStyle(TouchpadStyle)
is
called.public Actor hit(float x, float y, boolean touchable)
Actor
touchable
and
visible
, or null if no actor was hit. The point is specified in the actor's local coordinate system (0,0
is the bottom left of the actor and width,height is the upper right).
This method is used to delegate touchDown, mouse, and enter/exit events. If this method returns null, those events will not occur on this Actor.
The default implementation returns this actor if the point is within this actor's bounds.
hit
in class Actor
touchable
- If true, the hit detection will respect the touchability
.Touchable
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.public void draw(Batch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
public boolean isTouched()
public boolean getResetOnTouchUp()
public void setResetOnTouchUp(boolean reset)
reset
- Whether to reset the knob to the center on touch up.public void setDeadzone(float deadzoneRadius)
deadzoneRadius
- The distance in pixels from the center of the touchpad required for the knob to be moved.public float getKnobX()
public float getKnobY()
public float getKnobPercentX()
public float getKnobPercentY()
Copyright © 2015. All rights reserved.