actors. Stage handles the viewport and distributes input events.
setViewport(Viewport) controls the coordinates used within the stage and sets up the camera used to convert between
stage coordinates and screen coordinates.
A stage must receive input events so it can distribute them to actors. This is typically done by passing the stage to
Gdx.. An InputMultiplexer may
be used to handle input events before or after the stage does. If an actor handles an event by returning true from the input
method, then the stage's input method will also return true, causing subsequent InputProcessors to not receive the event.
The Stage and its constituents (like Actors and Listeners) are not thread-safe and should only be updated and queried from a single thread (presumably the main render thread). Methods should be reentrant, so you can update Actors and Stages from within callbacks and handlers.
| Modifier and Type | Class and Description |
|---|---|
| public static class | Stage.
Internal class for managing touch focus. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final Batch | |
| pack-priv static boolean | debug
True if any actor has ever had debug enabled. |
| private boolean | |
| private final Color | |
| private boolean | |
| private boolean | |
| private ShapeRenderer | |
| private Table. | |
| private boolean | |
| private Actor | |
| private Actor | |
| private int | |
| private int | |
| private boolean | |
| private final Actor[] | |
| private final int[] | |
| private final int[] | |
| private final boolean[] | |
| protected PoolManager | |
| private Group | |
| private Actor | |
| private final Vector2 | |
| pack-priv final SnapshotArray | |
| private Viewport |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | act(float
Time in seconds since the last frame. delta)Calls the |
| protected void | |
| public void | |
| public void | |
| public boolean | |
| public boolean | |
| public void | addTouchFocus(EventListener listener, Actor listenerActor, Actor target, int pointer, int button)
Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button. |
| public void | calculateScissors(Rectangle localRect, Rectangle scissorRect)
Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix. |
| public void | cancelTouchFocus(Actor listenerActor)
Cancels touch focus for all listeners with the specified listener actor. |
| public void | |
| public void | cancelTouchFocusExcept(EventListener exceptListener, Actor exceptActor)
Cancels touch focus for all listeners except the specified listener. |
| public void | |
| private void | disableDebug(Actor actor, Actor except)
Disables debug on all actors recursively except the specified actor and any children. |
| public void | dispose()
Implements com. Releases all resources of this object. |
| public void | |
| private void | |
| private Actor | |
| private void | |
| public boolean | |
| public Array | |
| public Batch | |
| public Camera | |
| public Color | |
| public float | |
| public Actor | |
| public Group | |
| public Actor | |
| public Viewport | |
| public float | |
| public Actor | Returns: May be null if no actor was hit.If true, the hit detection will respect the touchable)touchability.Returns the |
| public boolean | |
| protected boolean | isInsideViewport(int screenX, int screenY)
Check if screen coordinates are inside the viewport's screen area. |
| public boolean | keyDown(int keyCode)
Overrides com. Implements com. Applies a key down event to the actor that has |
| public boolean | keyTyped(char character)
Overrides com. Implements com. Applies a key typed event to the actor that has |
| public boolean | keyUp(int keyCode)
Overrides com. Implements com. Applies a key up event to the actor that has |
| public boolean | mouseMoved(int screenX, int screenY)
Overrides com. Implements com. Applies a mouse moved event to the stage and returns true if an actor in the scene |
| public boolean | |
| public boolean | |
| public void | removeTouchFocus(EventListener listener, Actor listenerActor, Actor target, int pointer, int button)
Removes touch focus for the specified listener, pointer, and button. |
| public Vector2 | screenToStageCoordinates(Vector2
Input screen coordinates and output for resulting stage coordinates. screenCoords)Transforms the screen coordinates to stage coordinates. |
| public boolean | scrolled(float amountX, float amountY)
Overrides com. Implements com. Applies a mouse scroll event to the stage and returns true if an actor in the scene |
| public void | setActionsRequestRendering(boolean actionsRequestRendering)
If true, any actions executed during a call to |
| public void | |
| public void | setDebugInvisible(boolean debugInvisible)
If true, debug lines are shown for actors even when |
| public void | setDebugParentUnderMouse(boolean debugParentUnderMouse)
If true, debug is enabled only for the parent of the actor under the mouse. |
| public void | setDebugTableUnderMouse(Table.
May be null for debugTableUnderMouseDebug#none.If not |
| public void | setDebugTableUnderMouse(boolean debugTableUnderMouse)
If true, debug is enabled only for the first ascendant of the actor under the mouse that is a table. |
| public void | setDebugUnderMouse(boolean debugUnderMouse)
If true, debug is enabled only for the actor under the mouse. |
| public boolean | Returns: true if the unfocus and focus events were not cancelled by aFocusListener.May be null. actor)Sets the actor that will receive key events. |
| public void | |
| public boolean | Returns: true if the unfocus and focus events were not cancelled by aFocusListener.May be null. actor)Sets the actor that will receive scroll events. |
| public void | |
| public Vector2 | stageToScreenCoordinates(Vector2
Input stage coordinates and output for resulting screen coordinates. stageCoords)Transforms the stage coordinates to screen coordinates. |
| public Vector2 | toScreenCoordinates(Vector2 coords, Matrix4 transformMatrix)
Transforms the coordinates to screen coordinates. |
| public boolean | touchCancelled(int screenX, int screenY, int pointer, int button)
Overrides com. Implements com. Called when the touch gesture is cancelled. |
| public boolean | touchDown(int screenX, int screenY, int pointer, int button)
Overrides com. Implements com. Applies a touch down event to the stage and returns true if an actor in the scene |
| public boolean | touchDragged(int screenX, int screenY, int pointer)
Overrides com. Implements com. Applies a touch moved event to the stage and returns true if an actor in the scene |
| public boolean | touchUp(int screenX, int screenY, int pointer, int button)
Overrides com. Implements com. Applies a touch up event to the stage and returns true if an actor in the scene |
| public void | |
| public void |
| actionsRequestRendering | back to summary |
|---|---|
| private boolean actionsRequestRendering | |
| batch | back to summary |
|---|---|
| private final Batch batch | |
| debug | back to summary |
|---|---|
| pack-priv static boolean debug True if any actor has ever had debug enabled. | |
| debugAll | back to summary |
|---|---|
| private boolean debugAll | |
| debugColor | back to summary |
|---|---|
| private final Color debugColor | |
| debugInvisible | back to summary |
|---|---|
| private boolean debugInvisible | |
| debugParentUnderMouse | back to summary |
|---|---|
| private boolean debugParentUnderMouse | |
| debugShapes | back to summary |
|---|---|
| private ShapeRenderer debugShapes | |
| debugTableUnderMouse | back to summary |
|---|---|
| private Table. | |
| debugUnderMouse | back to summary |
|---|---|
| private boolean debugUnderMouse | |
| keyboardFocus | back to summary |
|---|---|
| private Actor keyboardFocus
| |
| mouseOverActor | back to summary |
|---|---|
| private Actor mouseOverActor
| |
| mouseScreenX | back to summary |
|---|---|
| private int mouseScreenX | |
| mouseScreenY | back to summary |
|---|---|
| private int mouseScreenY | |
| ownsBatch | back to summary |
|---|---|
| private boolean ownsBatch | |
| pointerOverActors | back to summary |
|---|---|
| private final Actor[] pointerOverActors | |
| pointerScreenX | back to summary |
|---|---|
| private final int[] pointerScreenX | |
| pointerScreenY | back to summary |
|---|---|
| private final int[] pointerScreenY | |
| pointerTouched | back to summary |
|---|---|
| private final boolean[] pointerTouched | |
| pools | back to summary |
|---|---|
| protected PoolManager pools | |
| root | back to summary |
|---|---|
| private Group root | |
| scrollFocus | back to summary |
|---|---|
| private Actor scrollFocus
| |
| tempCoords | back to summary |
|---|---|
| private final Vector2 tempCoords | |
| touchFocuses | back to summary |
|---|---|
| pack-priv final SnapshotArray<Stage. | |
| viewport | back to summary |
|---|---|
| private Viewport viewport | |
| Stage | back to summary |
|---|---|
| public Stage() Creates a stage with a | |
| Stage | back to summary |
|---|---|
| public Stage(Viewport viewport) Creates a stage with the specified viewport. The stage will use its own | |
| Stage | back to summary |
|---|---|
| public Stage(Viewport viewport, Batch batch) Creates a stage with the specified viewport and batch. This can be used to specify an existing batch or to customize which batch implementation is used. | |
| act | back to summary |
|---|---|
| public void act() Calls | |
| act | back to summary |
|---|---|
| public void act(float delta) Calls the
| |
| actorRemoved | back to summary |
|---|---|
| protected void actorRemoved(Actor actor) Called just before an actor is removed from a group.
The default implementation fires an | |
| addAction | back to summary |
|---|---|
| public void addAction(Action action) Adds an action to the root of the stage.
| |
| addActor | back to summary |
|---|---|
| public void addActor(Actor actor) Adds an actor to the root of the stage.
| |
| addCaptureListener | back to summary |
|---|---|
| public boolean addCaptureListener(EventListener listener) Adds a capture listener to the root. | |
| addListener | back to summary |
|---|---|
| public boolean addListener(EventListener listener) Adds a listener to the root.
| |
| addTouchFocus | back to summary |
|---|---|
| public void addTouchFocus(EventListener listener, Actor listenerActor, Actor target, int pointer, int button) Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button. Touch focus
is added automatically when true is returned from | |
| calculateScissors | back to summary |
|---|---|
| public void calculateScissors(Rectangle localRect, Rectangle scissorRect) Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix. | |
| cancelTouchFocus | back to summary |
|---|---|
| public void cancelTouchFocus(Actor listenerActor) Cancels touch focus for all listeners with the specified listener actor.
| |
| cancelTouchFocus | back to summary |
|---|---|
| public void cancelTouchFocus() Removes all touch focus listeners, sending a touchUp event to each listener. Listeners typically expect to receive a
touchUp event when they have touch focus. The location of the touchUp is | |
| cancelTouchFocusExcept | back to summary |
|---|---|
| public void cancelTouchFocusExcept(EventListener exceptListener, Actor exceptActor) Cancels touch focus for all listeners except the specified listener.
| |
| clear | back to summary |
|---|---|
| public void clear() Removes the root's children, actions, and listeners. | |
| disableDebug | back to summary |
|---|---|
| private void disableDebug(Actor actor, Actor except) Disables debug on all actors recursively except the specified actor and any children. | |
| dispose | back to summary |
|---|---|
| public void dispose() Implements com. Doc from com. Releases all resources of this object. | |
| draw | back to summary |
|---|---|
| public void draw() | |
| drawDebug | back to summary |
|---|---|
| private void drawDebug() | |
| fireEnterAndExit | back to summary |
|---|---|
private Actor fireEnterAndExit(Actor overLast, int screenX, int screenY, int pointer)
| |
| fireExit | back to summary |
|---|---|
| private void fireExit(Actor actor, int screenX, int screenY, int pointer) | |
| getActionsRequestRendering | back to summary |
|---|---|
| public boolean getActionsRequestRendering() | |
| getActors | back to summary |
|---|---|
| public Array Returns the root's child actors.
| |
| getBatch | back to summary |
|---|---|
| public Batch getBatch() | |
| getCamera | back to summary |
|---|---|
| public Camera getCamera() The viewport's camera. | |
| getDebugColor | back to summary |
|---|---|
| public Color getDebugColor() The default color that can be used by actors to draw debug lines. | |
| getHeight | back to summary |
|---|---|
| public float getHeight() The viewport's world height. | |
| getKeyboardFocus | back to summary |
|---|---|
| public Actor getKeyboardFocus() Gets the actor that will receive key events. | |
| getRoot | back to summary |
|---|---|
| public Group getRoot() Returns the root group which holds all actors in the stage. | |
| getScrollFocus | back to summary |
|---|---|
| public Actor getScrollFocus() Gets the actor that will receive scroll events. | |
| getViewport | back to summary |
|---|---|
| public Viewport getViewport() | |
| getWidth | back to summary |
|---|---|
| public float getWidth() The viewport's world width. | |
| hit | back to summary |
|---|---|
| public Actor hit(float stageX, float stageY, boolean touchable) Returns the
| |
| isDebugAll | back to summary |
|---|---|
| public boolean isDebugAll() | |
| isInsideViewport | back to summary |
|---|---|
| protected boolean isInsideViewport(int screenX, int screenY) Check if screen coordinates are inside the viewport's screen area. | |
| keyDown | back to summary |
|---|---|
| public boolean keyDown(int keyCode) Overrides com. Implements com. Applies a key down event to the actor that has | |
| keyTyped | back to summary |
|---|---|
| public boolean keyTyped(char character) Overrides com. Implements com. Applies a key typed event to the actor that has | |
| keyUp | back to summary |
|---|---|
| public boolean keyUp(int keyCode) Overrides com. Implements com. Applies a key up event to the actor that has | |
| mouseMoved | back to summary |
|---|---|
| public boolean mouseMoved(int screenX, int screenY) Overrides com. Implements com. Applies a mouse moved event to the stage and returns true if an actor in the scene | |
| removeCaptureListener | back to summary |
|---|---|
| public boolean removeCaptureListener(EventListener listener) Removes a listener from the root. | |
| removeListener | back to summary |
|---|---|
| public boolean removeListener(EventListener listener) Removes a listener from the root.
| |
| removeTouchFocus | back to summary |
|---|---|
| public void removeTouchFocus(EventListener listener, Actor listenerActor, Actor target, int pointer, int button) Removes touch focus for the specified listener, pointer, and button. Note the listener will not receive a touchUp event when this method is used. | |
| screenToStageCoordinates | back to summary |
|---|---|
| public Vector2 screenToStageCoordinates(Vector2 screenCoords) Transforms the screen coordinates to stage coordinates.
| |
| scrolled | back to summary |
|---|---|
| public boolean scrolled(float amountX, float amountY) Overrides com. Implements com. Applies a mouse scroll event to the stage and returns true if an actor in the scene | |
| setActionsRequestRendering | back to summary |
|---|---|
| public void setActionsRequestRendering(boolean actionsRequestRendering) If true, any actions executed during a call to | |
| setDebugAll | back to summary |
|---|---|
| public void setDebugAll(boolean debugAll) If true, debug lines are shown for all actors. | |
| setDebugInvisible | back to summary |
|---|---|
| public void setDebugInvisible(boolean debugInvisible) If true, debug lines are shown for actors even when | |
| setDebugParentUnderMouse | back to summary |
|---|---|
| public void setDebugParentUnderMouse(boolean debugParentUnderMouse) If true, debug is enabled only for the parent of the actor under the mouse. Can be combined with
| |
| setDebugTableUnderMouse | back to summary |
|---|---|
| public void setDebugTableUnderMouse(Table. If not
| |
| setDebugTableUnderMouse | back to summary |
|---|---|
| public void setDebugTableUnderMouse(boolean debugTableUnderMouse) If true, debug is enabled only for the first ascendant of the actor under the mouse that is a table. Can be combined with
| |
| setDebugUnderMouse | back to summary |
|---|---|
| public void setDebugUnderMouse(boolean debugUnderMouse) If true, debug is enabled only for the actor under the mouse. Can be combined with | |
| setKeyboardFocus | back to summary |
|---|---|
| public boolean setKeyboardFocus(Actor actor) Sets the actor that will receive key events.
| |
| setRoot | back to summary |
|---|---|
| public void setRoot(Group root) Replaces the root group. This can be useful, for example, to subclass the root group to be notified by
| |
| setScrollFocus | back to summary |
|---|---|
| public boolean setScrollFocus(Actor actor) Sets the actor that will receive scroll events.
| |
| setViewport | back to summary |
|---|---|
| public void setViewport(Viewport viewport) | |
| stageToScreenCoordinates | back to summary |
|---|---|
| public Vector2 stageToScreenCoordinates(Vector2 stageCoords) Transforms the stage coordinates to screen coordinates.
| |
| toScreenCoordinates | back to summary |
|---|---|
| public Vector2 toScreenCoordinates(Vector2 coords, Matrix4 transformMatrix) Transforms the coordinates to screen coordinates. The coordinates can be anywhere in the stage since the transform matrix
describes how to convert them. The transform matrix is typically obtained from | |
| touchCancelled | back to summary |
|---|---|
| public boolean touchCancelled(int screenX, int screenY, int pointer, int button) Overrides com. Implements com. Doc from com. Called when the touch gesture is cancelled. Reason may be from OS interruption to touch becoming a large surface such as
the user cheek). Relevant on Android and iOS only. The button parameter will be | |
| touchDown | back to summary |
|---|---|
| public boolean touchDown(int screenX, int screenY, int pointer, int button) Overrides com. Implements com. Applies a touch down event to the stage and returns true if an actor in the scene | |
| touchDragged | back to summary |
|---|---|
| public boolean touchDragged(int screenX, int screenY, int pointer) Overrides com. Implements com. Applies a touch moved event to the stage and returns true if an actor in the scene | |
| touchUp | back to summary |
|---|---|
| public boolean touchUp(int screenX, int screenY, int pointer, int button) Overrides com. Implements com. Applies a touch up event to the stage and returns true if an actor in the scene | |
| unfocus | back to summary |
|---|---|
| public void unfocus(Actor actor) Removes the touch, keyboard, and scroll focus for the specified actor and any descendants. | |
| unfocusAll | back to summary |
|---|---|
| public void unfocusAll() Removes the touch, keyboard, and scroll focused actors. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv EventListener | |
| pack-priv Actor | |
| pack-priv int | |
| pack-priv Actor |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| button | back to summary |
|---|---|
| pack-priv int button | |
| listener | back to summary |
|---|---|
| pack-priv EventListener listener | |
| listenerActor | back to summary |
|---|---|
| pack-priv Actor listenerActor | |
| pointer | back to summary |
|---|---|
| pack-priv int pointer | |
| target | back to summary |
|---|---|
| pack-priv Actor target | |
| TouchFocus | back to summary |
|---|---|
| public TouchFocus() | |
| reset | back to summary |
|---|---|
| public void reset() Implements com. Doc from com. Resets the object for reuse. Object references should be nulled and fields may be set to default values. | |