Package net.dermetfan.gdx.scenes.scene2d
Class Scene2DUtils
java.lang.Object
net.dermetfan.gdx.scenes.scene2d.Scene2DUtils
public class Scene2DUtils
extends java.lang.Object
provides useful methods for scene2d
-
Constructor Summary
Constructors Constructor Description Scene2DUtils()
-
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.static com.badlogic.gdx.math.Vector2
stageToLocalCoordinates(com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.scenes.scene2d.Actor actor)
Deprecated.useActor.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:
c
- the event to copy frome
- the event to copy to
-
copy
public static void copy(com.badlogic.gdx.scenes.scene2d.InputEvent e, com.badlogic.gdx.scenes.scene2d.InputEvent c)- See Also:
copy(Event, Event)
-
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 coordinatesactor
- the actor in which coordinate system pos is givenother
- the actor into which coordinate system to convert the coordinates to- Returns:
- the given position, converted
- Throws:
java.lang.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.useActor.stageToLocalCoordinates(Vector2)
- Parameters:
pos
- the positionactor
- 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.useActor.stageToLocalCoordinates(Vector2)
- See Also:
stageToLocalCoordinates(Vector2, Actor)
-
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 GroupnewParent
- 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(Stage, int)
-
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 usedpointer
- 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 areaheight
- the height of the areaalign
- theAlign
flag- Returns:
- the aligned local position
- Since:
- 0.8.0
-
Actor.stageToLocalCoordinates(Vector2)