Class Scene2DUtils

java.lang.Object
net.dermetfan.gdx.scenes.scene2d.Scene2DUtils

public class Scene2DUtils extends Object
provides useful methods for scene2d
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addAtStageCoordinates(com.badlogic.gdx.scenes.scene2d.Actor actor, com.badlogic.gdx.scenes.scene2d.Group newParent)
    Adds the given Actor to the given Group at the coordinates relative to the Stage.
    static com.badlogic.gdx.math.Vector2
    align(float width, float height, int align)
     
    static void
    copy(com.badlogic.gdx.scenes.scene2d.Event e, com.badlogic.gdx.scenes.scene2d.Event c)
     
    static void
    copy(com.badlogic.gdx.scenes.scene2d.InputEvent e, com.badlogic.gdx.scenes.scene2d.InputEvent c)
     
    static com.badlogic.gdx.scenes.scene2d.Group
    lastParent(com.badlogic.gdx.scenes.scene2d.Actor actor)
     
    static com.badlogic.gdx.math.Vector2
    localToOtherCoordinates(com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.scenes.scene2d.Actor actor, com.badlogic.gdx.scenes.scene2d.Actor other)
     
    static com.badlogic.gdx.math.Vector2
    pointerPosition(com.badlogic.gdx.scenes.scene2d.Stage stage)
     
    static com.badlogic.gdx.math.Vector2
    pointerPosition(com.badlogic.gdx.scenes.scene2d.Stage stage, int pointer)
     
    static com.badlogic.gdx.math.Vector2
    positionInStageCoordinates(com.badlogic.gdx.scenes.scene2d.Actor actor)
     
    static com.badlogic.gdx.math.Vector2
    stageToLocalCoordinates(float x, float y, com.badlogic.gdx.scenes.scene2d.Actor actor)
    Deprecated.
    use Actor.stageToLocalCoordinates(Vector2)
    static com.badlogic.gdx.math.Vector2
    stageToLocalCoordinates(com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.scenes.scene2d.Actor actor)
    Deprecated.
    use Actor.stageToLocalCoordinates(Vector2)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Scene2DUtils

      public Scene2DUtils()
  • Method Details

    • copy

      public static void copy(com.badlogic.gdx.scenes.scene2d.Event e, com.badlogic.gdx.scenes.scene2d.Event c)
      Parameters:
      e - the event to copy to
      c - the event to copy from
    • copy

      public static void copy(com.badlogic.gdx.scenes.scene2d.InputEvent e, com.badlogic.gdx.scenes.scene2d.InputEvent c)
      See Also:
    • localToOtherCoordinates

      public static com.badlogic.gdx.math.Vector2 localToOtherCoordinates(com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.scenes.scene2d.Actor actor, com.badlogic.gdx.scenes.scene2d.Actor other)
      Parameters:
      pos - the coordinates
      actor - the actor in which coordinate system pos is given
      other - the actor into which coordinate system to convert the coordinates to
      Returns:
      the given position, converted
      Throws:
      IllegalArgumentException - if the given actors are not in the same hierarchy
    • stageToLocalCoordinates

      @Deprecated public static com.badlogic.gdx.math.Vector2 stageToLocalCoordinates(com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.scenes.scene2d.Actor actor)
      Deprecated.
      use Actor.stageToLocalCoordinates(Vector2)
      Parameters:
      pos - the position
      actor - the actor to which coordinate system to convert
    • stageToLocalCoordinates

      @Deprecated public static com.badlogic.gdx.math.Vector2 stageToLocalCoordinates(float x, float y, com.badlogic.gdx.scenes.scene2d.Actor actor)
      Deprecated.
      use Actor.stageToLocalCoordinates(Vector2)
      See Also:
    • lastParent

      public static com.badlogic.gdx.scenes.scene2d.Group lastParent(com.badlogic.gdx.scenes.scene2d.Actor actor)
      Returns:
      the highest parent in the hierarchy tree of the given actor
    • positionInStageCoordinates

      public static com.badlogic.gdx.math.Vector2 positionInStageCoordinates(com.badlogic.gdx.scenes.scene2d.Actor actor)
      Parameters:
      actor - the actor which position in stage coordinates to return
      Returns:
      the position of the given actor in the stage coordinate system
    • addAtStageCoordinates

      public static void addAtStageCoordinates(com.badlogic.gdx.scenes.scene2d.Actor actor, com.badlogic.gdx.scenes.scene2d.Group newParent)
      Adds the given Actor to the given Group at the coordinates relative to the Stage.
      Parameters:
      actor - the Actor to add to the given Group
      newParent - the Group to add the given Actor to
    • pointerPosition

      public static com.badlogic.gdx.math.Vector2 pointerPosition(com.badlogic.gdx.scenes.scene2d.Stage stage)
      See Also:
    • pointerPosition

      public static com.badlogic.gdx.math.Vector2 pointerPosition(com.badlogic.gdx.scenes.scene2d.Stage stage, int pointer)
      Parameters:
      stage - the Stage which coordinate system should be used
      pointer - the pointer which position to return
      Returns:
      the position of the given pointer in stage coordinates
    • align

      public static com.badlogic.gdx.math.Vector2 align(float width, float height, int align)
      Parameters:
      width - the width of the area
      height - the height of the area
      align - the Align flag
      Returns:
      the aligned local position
      Since:
      0.8.0