Package arc.scene
Class Scene
java.lang.Object
arc.scene.Scene
- All Implemented Interfaces:
InputProcessor
-
Field Summary
Modifier and TypeFieldDescriptionfloat
Margins for fill layouts.float
Margins for fill layouts.float
Margins for fill layouts.float
Margins for fill layouts.final Group
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
act()
Callsact(float)
withGraphics.getDeltaTime()
.void
act
(float delta) Calls theElement.act(float)
method on each actor in the stage.void
Adds an actor to the root of the stage.void
Adds an action to the root of the stage.boolean
addCaptureListener
(EventListener listener) Adds a capture listener to the root.boolean
addListener
(EventListener listener) Adds a listener to the root.<T> void
void
addTouchFocus
(EventListener listener, Element listenerActor, Element target, int pointer, KeyCode button) Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button.void
calculateScissors
(Rect localRect, Rect scissorRect) Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix.void
Sends a touchUp event to all listeners that are registered to receive touchDragged and touchUp events and removes their touch focus.void
cancelTouchFocus
(Element actor) Cancels touch focus for the specified actor.void
cancelTouchFocusExcept
(EventListener exceptListener, Element exceptActor) Cancels touch focus for all listeners except the specified listener.void
clear()
Removes the root's children, actions, and listeners.void
draw()
findVisible
(String name) boolean
The viewport's camera.Returns the root's child actors.float
The viewport's world height.Gets the actor that will receive key events.Gets the actor that will receive scroll events.<T> T
float
getWidth()
The viewport's world width.boolean
boolean
hasField()
boolean
boolean
hasMouse()
boolean
hasMouse
(float mousex, float mousey) boolean
<T> boolean
hit
(float stageX, float stageY, boolean touchable) Returns theElement
at the specified location in stage coordinates.protected boolean
isInsideViewport
(int screenX, int screenY) Check if screen coordinates are inside the viewport's screen area.boolean
Applies a key down event to the actor that haskeyboard focus
, if any, and returns true if the event washandled
.boolean
keyTyped
(char character) Applies a key typed event to the actor that haskeyboard focus
, if any, and returns true if the event washandled
.boolean
Applies a key up event to the actor that haskeyboard focus
, if any, and returns true if the event washandled
.boolean
mouseMoved
(int screenX, int screenY) Applies a mouse moved event to the stage and returns true if an actor in the scenehandled
the event.void
registerStyles
(Class<?> type) void
registerStyles
(Object obj) boolean
removeCaptureListener
(EventListener listener) Removes a listener from the root.boolean
removeListener
(EventListener listener) Removes a listener from the root.void
removeTouchFocus
(EventListener listener, Element listenerActor, Element target, int pointer, KeyCode button) Removes the listener from being notified for all touchDragged and touchUp events for the specified pointer and button.void
resize
(int width, int height) Updates the viewport.screenToStageCoordinates
(Vec2 screenCoords) Transforms the screen coordinates to stage coordinates.boolean
scrolled
(float amountX, float amountY) Applies a mouse scroll event to the stage and returns true if an actor in the scenehandled
the event.void
setActionsRequestRendering
(boolean actionsRequestRendering) If true, any actions executed during a call toact()
) will result in a call toGraphics.requestRendering()
.boolean
setKeyboardFocus
(Element actor) Sets the actor that will receive key events.boolean
setScrollFocus
(Element actor) Sets the actor that will receive scroll events.void
setViewport
(Viewport viewport) stageToScreenCoordinates
(Vec2 stageCoords) Transforms the stage coordinates to screen coordinates.table()
Adds and returns a table.Adds and returns a table.Adds and returns a table.toScreenCoordinates
(Vec2 coords, Mat transformMatrix) Transforms the coordinates to screen coordinates.boolean
Applies a touch down event to the stage and returns true if an actor in the scenehandled
the event.boolean
touchDragged
(int screenX, int screenY, int pointer) Applies a touch moved event to the stage and returns true if an actor in the scenehandled
the event.boolean
Applies a touch up event to the stage and returns true if an actor in the scenehandled
the event.void
Removes the touch, keyboard, and scroll focus for the specified actor and any descendants.void
Removes the touch, keyboard, and scroll focused actors.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface arc.input.InputProcessor
connected, disconnected
-
Field Details
-
root
-
marginLeft
public float marginLeftMargins for fill layouts. -
marginRight
public float marginRightMargins for fill layouts. -
marginTop
public float marginTopMargins for fill layouts. -
marginBottom
public float marginBottomMargins for fill layouts.
-
-
Constructor Details
-
Scene
public Scene() -
Scene
-
-
Method Details
-
getStyle
-
hasStyle
-
addStyle
-
registerStyles
-
registerStyles
-
hasField
public boolean hasField() -
hasMouse
public boolean hasMouse() -
hasMouse
public boolean hasMouse(float mousex, float mousey) -
hasDialog
public boolean hasDialog() -
hasKeyboard
public boolean hasKeyboard() -
hasScroll
public boolean hasScroll() -
getDialog
-
draw
public void draw() -
act
public void act()Callsact(float)
withGraphics.getDeltaTime()
. -
act
public void act(float delta) Calls theElement.act(float)
method on each actor in the stage. Typically called each frame. This method also fires enter and exit events.- Parameters:
delta
- Time in seconds since the last frame.
-
find
-
findVisible
-
find
-
table
Adds and returns a table. This table will fill the whole scene. -
table
Adds and returns a table. This table will fill the whole scene. -
table
Adds and returns a table. This table will fill the whole scene. -
touchDown
Applies a touch down event to the stage and returns true if an actor in the scenehandled
the event.- Specified by:
touchDown
in interfaceInputProcessor
- Parameters:
screenX
- The x coordinate, origin is in the upper left cornerscreenY
- The y coordinate, origin is in the upper left cornerpointer
- the pointer for the event.button
- the button- Returns:
- whether the input was processed
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer) Applies a touch moved event to the stage and returns true if an actor in the scenehandled
the event. Onlylisteners
that returned true for touchDown will receive this event.- Specified by:
touchDragged
in interfaceInputProcessor
pointer
- the pointer for the event.- Returns:
- whether the input was processed
-
touchUp
Applies a touch up event to the stage and returns true if an actor in the scenehandled
the event. Onlylisteners
that returned true for touchDown will receive this event.- Specified by:
touchUp
in interfaceInputProcessor
pointer
- the pointer for the event.button
- the button- Returns:
- whether the input was processed
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY) Applies a mouse moved event to the stage and returns true if an actor in the scenehandled
the event. This event only occurs on the desktop.- Specified by:
mouseMoved
in interfaceInputProcessor
- Returns:
- whether the input was processed
-
scrolled
public boolean scrolled(float amountX, float amountY) Applies a mouse scroll event to the stage and returns true if an actor in the scenehandled
the event. This event only occurs on the desktop.- Specified by:
scrolled
in interfaceInputProcessor
- Parameters:
amountX
- the horizontal scroll amount, negative or positive depending on the direction the wheel was scrolled.amountY
- the vertical scroll amount, negative or positive depending on the direction the wheel was scrolled.- Returns:
- whether the input was processed.
-
keyDown
Applies a key down event to the actor that haskeyboard focus
, if any, and returns true if the event washandled
.- Specified by:
keyDown
in interfaceInputProcessor
- Returns:
- whether the input was processed
-
keyUp
Applies a key up event to the actor that haskeyboard focus
, if any, and returns true if the event washandled
.- Specified by:
keyUp
in interfaceInputProcessor
- Returns:
- whether the input was processed
-
keyTyped
public boolean keyTyped(char character) Applies a key typed event to the actor that haskeyboard focus
, if any, and returns true if the event washandled
.- Specified by:
keyTyped
in interfaceInputProcessor
- Parameters:
character
- The character- Returns:
- whether the input was processed
-
addTouchFocus
public void addTouchFocus(EventListener listener, Element listenerActor, Element target, int pointer, KeyCode button) Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button. -
removeTouchFocus
public void removeTouchFocus(EventListener listener, Element listenerActor, Element target, int pointer, KeyCode button) Removes the listener from being notified for all touchDragged and touchUp events for the specified pointer and button. Note the listener may never receive a touchUp event if this method is used. -
cancelTouchFocus
Cancels touch focus for the specified actor.- See Also:
-
cancelTouchFocus
public void cancelTouchFocus()Sends a touchUp event to all listeners that are registered to receive touchDragged and touchUp events and removes their touch focus. This method removes all touch focus listeners, but sends a touchUp event so that the state of the listeners remains consistent (listeners typically expect to receive touchUp eventually). The location of the touchUp is Integer#MIN_VALUE. Listeners can useInputEvent.isTouchFocusCancel()
to ignore this event if needed. -
cancelTouchFocusExcept
Cancels touch focus for all listeners except the specified listener.- See Also:
-
add
Adds an actor to the root of the stage.- See Also:
-
addAction
Adds an action to the root of the stage.- See Also:
-
getElements
Returns the root's child actors.- See Also:
-
addListener
Adds a listener to the root.- See Also:
-
removeListener
Removes a listener from the root.- See Also:
-
addCaptureListener
Adds a capture listener to the root. -
removeCaptureListener
Removes a listener from the root. -
clear
public void clear()Removes the root's children, actions, and listeners. -
unfocusAll
public void unfocusAll()Removes the touch, keyboard, and scroll focused actors. -
unfocus
Removes the touch, keyboard, and scroll focus for the specified actor and any descendants. -
setKeyboardFocus
Sets the actor that will receive key events.- Parameters:
actor
- May be null.- Returns:
- true if the unfocus and focus events were not cancelled by a
FocusListener
.
-
getKeyboardFocus
Gets the actor that will receive key events.- Returns:
- May be null.
-
setScrollFocus
Sets the actor that will receive scroll events.- Parameters:
actor
- May be null.- Returns:
- true if the unfocus and focus events were not cancelled by a
FocusListener
.
-
getScrollFocus
Gets the actor that will receive scroll events.- Returns:
- May be null.
-
getViewport
-
setViewport
-
getWidth
public float getWidth()The viewport's world width. -
getHeight
public float getHeight()The viewport's world height. -
getCamera
The viewport's camera. -
hit
Returns theElement
at the specified location in stage coordinates. Hit testing is performed in the order the actors were inserted into the stage, last inserted actors being tested first. To get stage coordinates from screen coordinates, usescreenToStageCoordinates(Vec2)
.- Parameters:
touchable
- If true, the hit detection will respect the touchability.- Returns:
- May be null if no actor was hit.
-
screenToStageCoordinates
Transforms the screen coordinates to stage coordinates.- Parameters:
screenCoords
- Input screen coordinates and output for resulting stage coordinates.
-
stageToScreenCoordinates
Transforms the stage coordinates to screen coordinates.- Parameters:
stageCoords
- Input stage coordinates and output for resulting screen coordinates.
-
toScreenCoordinates
Transforms the coordinates to screen coordinates. The coordinates can be anywhere in the stage since the transform matrix describes how to convert them.- See Also:
-
calculateScissors
Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix. -
getActionsRequestRendering
public boolean getActionsRequestRendering() -
setActionsRequestRendering
public void setActionsRequestRendering(boolean actionsRequestRendering) If true, any actions executed during a call toact()
) will result in a call toGraphics.requestRendering()
. Widgets that animate or otherwise require additional rendering may check this setting before callingGraphics.requestRendering()
. Default is true. -
isInsideViewport
protected boolean isInsideViewport(int screenX, int screenY) Check if screen coordinates are inside the viewport's screen area. -
resize
public void resize(int width, int height) Updates the viewport.
-