Example usage for com.badlogic.gdx.scenes.scene2d Actor hasParent

List of usage examples for com.badlogic.gdx.scenes.scene2d Actor hasParent

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Actor hasParent.

Prototype

public boolean hasParent() 

Source Link

Document

Returns true if the actor's parent is not null.

Usage

From source file:com.blastedstudios.gdxworld.util.ui.Scene2DUtils.java

License:Apache License

/** @return the highest parent in the hierarchy tree of the given actor */
public static Group lastParent(Actor actor) {
    if (!actor.hasParent())
        return null;
    Group parent = actor.getParent();
    while (parent.hasParent())
        parent = parent.getParent();/*  w w  w . j  a v a2 s  .c  o m*/
    assert !parent.hasParent();
    return parent;
}

From source file:com.blastedstudios.gdxworld.util.ui.Scene2DUtils.java

License:Apache License

/** @param actor the actor which position in stage coordinates to return
 *  @return the position of the given actor in the stage coordinate system */
public static Vector2 positionInStageCoordinates(Actor actor) {
    if (actor.hasParent())
        actor.localToStageCoordinates(tmp.set(0, 0));
    else//from ww  w.  j  a v a2s . co  m
        tmp.set(actor.getX(), actor.getY());
    return tmp;
}