Package arc.scene

Class Scene

java.lang.Object
arc.scene.Scene
All Implemented Interfaces:
InputProcessor

public class Scene extends Object implements InputProcessor
  • Field Details

    • root

      public final Group root
    • marginLeft

      public float marginLeft
      Margins for fill layouts.
    • marginRight

      public float marginRight
      Margins for fill layouts.
    • marginTop

      public float marginTop
      Margins for fill layouts.
    • marginBottom

      public float marginBottom
      Margins for fill layouts.
  • Constructor Details

    • Scene

      public Scene()
    • Scene

      public Scene(Viewport viewport)
  • Method Details

    • getStyle

      public <T> T getStyle(Class<T> type)
    • hasStyle

      public <T> boolean hasStyle(Class<T> type)
    • addStyle

      public <T> void addStyle(Class<T> type, T style)
    • registerStyles

      public void registerStyles(Class<?> type)
    • registerStyles

      public void registerStyles(Object obj)
    • 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

      public Dialog getDialog()
    • draw

      public void draw()
    • act

      public void act()
    • act

      public void act(float delta)
      Calls the Element.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

      public Element find(String name)
    • findVisible

      public Element findVisible(String name)
    • find

      public Element find(Boolf<Element> pred)
    • table

      public Table table()
      Adds and returns a table. This table will fill the whole scene.
    • table

      public Table table(Cons<Table> cons)
      Adds and returns a table. This table will fill the whole scene.
    • table

      public Table table(Drawable style, Cons<Table> cons)
      Adds and returns a table. This table will fill the whole scene.
    • touchDown

      public boolean touchDown(int screenX, int screenY, int pointer, KeyCode button)
      Applies a touch down event to the stage and returns true if an actor in the scene handled the event.
      Specified by:
      touchDown in interface InputProcessor
      Parameters:
      screenX - The x coordinate, origin is in the upper left corner
      screenY - The y coordinate, origin is in the upper left corner
      pointer - 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 scene handled the event. Only listeners that returned true for touchDown will receive this event.
      Specified by:
      touchDragged in interface InputProcessor
      pointer - the pointer for the event.
      Returns:
      whether the input was processed
    • touchUp

      public boolean touchUp(int screenX, int screenY, int pointer, KeyCode button)
      Applies a touch up event to the stage and returns true if an actor in the scene handled the event. Only listeners that returned true for touchDown will receive this event.
      Specified by:
      touchUp in interface InputProcessor
      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 scene handled the event. This event only occurs on the desktop.
      Specified by:
      mouseMoved in interface InputProcessor
      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 scene handled the event. This event only occurs on the desktop.
      Specified by:
      scrolled in interface InputProcessor
      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

      public boolean keyDown(KeyCode keyCode)
      Applies a key down event to the actor that has keyboard focus, if any, and returns true if the event was handled.
      Specified by:
      keyDown in interface InputProcessor
      Returns:
      whether the input was processed
    • keyUp

      public boolean keyUp(KeyCode keyCode)
      Applies a key up event to the actor that has keyboard focus, if any, and returns true if the event was handled.
      Specified by:
      keyUp in interface InputProcessor
      Returns:
      whether the input was processed
    • keyTyped

      public boolean keyTyped(char character)
      Applies a key typed event to the actor that has keyboard focus, if any, and returns true if the event was handled.
      Specified by:
      keyTyped in interface InputProcessor
      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

      public void cancelTouchFocus(Element actor)
      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 use InputEvent.isTouchFocusCancel() to ignore this event if needed.
    • cancelTouchFocusExcept

      public void cancelTouchFocusExcept(EventListener exceptListener, Element exceptActor)
      Cancels touch focus for all listeners except the specified listener.
      See Also:
    • add

      public void add(Element actor)
      Adds an actor to the root of the stage.
      See Also:
    • addAction

      public void addAction(Action action)
      Adds an action to the root of the stage.
      See Also:
    • getElements

      public Seq<Element> getElements()
      Returns the root's child actors.
      See Also:
    • addListener

      public boolean addListener(EventListener listener)
      Adds a listener to the root.
      See Also:
    • removeListener

      public boolean removeListener(EventListener listener)
      Removes a listener from the root.
      See Also:
    • addCaptureListener

      public boolean addCaptureListener(EventListener listener)
      Adds a capture listener to the root.
      See Also:
    • removeCaptureListener

      public boolean removeCaptureListener(EventListener listener)
      Removes a listener from the root.
      See Also:
    • 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

      public void unfocus(Element actor)
      Removes the touch, keyboard, and scroll focus for the specified actor and any descendants.
    • setKeyboardFocus

      public boolean setKeyboardFocus(Element actor)
      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

      public Element getKeyboardFocus()
      Gets the actor that will receive key events.
      Returns:
      May be null.
    • setScrollFocus

      public boolean setScrollFocus(Element actor)
      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

      public Element getScrollFocus()
      Gets the actor that will receive scroll events.
      Returns:
      May be null.
    • getViewport

      public Viewport getViewport()
    • setViewport

      public void setViewport(Viewport viewport)
    • getWidth

      public float getWidth()
      The viewport's world width.
    • getHeight

      public float getHeight()
      The viewport's world height.
    • getCamera

      public Camera getCamera()
      The viewport's camera.
    • hit

      public Element hit(float stageX, float stageY, boolean touchable)
      Returns the Element 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, use screenToStageCoordinates(Vec2).
      Parameters:
      touchable - If true, the hit detection will respect the touchability.
      Returns:
      May be null if no actor was hit.
    • screenToStageCoordinates

      public Vec2 screenToStageCoordinates(Vec2 screenCoords)
      Transforms the screen coordinates to stage coordinates.
      Parameters:
      screenCoords - Input screen coordinates and output for resulting stage coordinates.
    • stageToScreenCoordinates

      public Vec2 stageToScreenCoordinates(Vec2 stageCoords)
      Transforms the stage coordinates to screen coordinates.
      Parameters:
      stageCoords - Input stage coordinates and output for resulting screen coordinates.
    • toScreenCoordinates

      public Vec2 toScreenCoordinates(Vec2 coords, Mat transformMatrix)
      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

      public void calculateScissors(Rect localRect, Rect scissorRect)
      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 to act()) will result in a call to Graphics.requestRendering() . Widgets that animate or otherwise require additional rendering may check this setting before calling Graphics.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.