Search in sources :

Example 11 with Group

use of com.badlogic.gdx.scenes.scene2d.Group in project libgdx by libgdx.

the class WidgetGroup method invalidateHierarchy.

public void invalidateHierarchy() {
    invalidate();
    Group parent = getParent();
    if (parent instanceof Layout)
        ((Layout) parent).invalidateHierarchy();
}
Also used : Group(com.badlogic.gdx.scenes.scene2d.Group) Layout(com.badlogic.gdx.scenes.scene2d.utils.Layout)

Example 12 with Group

use of com.badlogic.gdx.scenes.scene2d.Group in project libgdx by libgdx.

the class WidgetGroup method validate.

public void validate() {
    if (!layoutEnabled)
        return;
    Group parent = getParent();
    if (fillParent && parent != null) {
        float parentWidth, parentHeight;
        Stage stage = getStage();
        if (stage != null && parent == stage.getRoot()) {
            parentWidth = stage.getWidth();
            parentHeight = stage.getHeight();
        } else {
            parentWidth = parent.getWidth();
            parentHeight = parent.getHeight();
        }
        if (getWidth() != parentWidth || getHeight() != parentHeight) {
            setWidth(parentWidth);
            setHeight(parentHeight);
            invalidate();
        }
    }
    if (!needsLayout)
        return;
    needsLayout = false;
    layout();
}
Also used : Group(com.badlogic.gdx.scenes.scene2d.Group) Stage(com.badlogic.gdx.scenes.scene2d.Stage)

Example 13 with Group

use of com.badlogic.gdx.scenes.scene2d.Group in project netthreads-libgdx by alistairrutherford.

the class SceneHelper method hit.

/**
	 * Find hit class.
	 * 
	 * @param x
	 *            Current x position.
	 * @param y
	 *            Current y position
	 * @param group
	 *            The starting Group.
	 * @param targetClass
	 *            The target class type.
	 * 
	 * @return The target or null if not found.
	 */
@SuppressWarnings("rawtypes")
public static Actor hit(float x, float y, Group group, Class targetClass) {
    SnapshotArray<Actor> children = group.getChildren();
    Actor hit = null;
    boolean found = false;
    int index = children.size - 1;
    while (!found && index >= 0) {
        Actor child = children.get(index);
        if (child.getClass().isAssignableFrom(targetClass)) {
            point.x = x;
            point.y = y;
            group.localToDescendantCoordinates(child, point);
            if (child.hit(point.x, point.y, true) != null) {
                found = true;
                hit = child;
            } else if (child instanceof Group) {
                child = hit(x, y, (Group) child, targetClass);
            }
        }
        index--;
    }
    return hit;
}
Also used : Group(com.badlogic.gdx.scenes.scene2d.Group) Actor(com.badlogic.gdx.scenes.scene2d.Actor)

Example 14 with Group

use of com.badlogic.gdx.scenes.scene2d.Group in project netthreads-libgdx by alistairrutherford.

the class SceneHelper method hit.

/**
	 * Look for target hit of specified class.
	 * 
	 * @param x
	 *            Current x position.
	 * @param y
	 *            Current y position
	 * @param stage
	 *            The starting stage.
	 * @param targetClass
	 *            The target class type.
	 * @return Target class or null if not found.
	 */
@SuppressWarnings("rawtypes")
public static Actor hit(float x, float y, Stage stage, Class targetClass) {
    Group root = stage.getRoot();
    SnapshotArray<Actor> children = root.getChildren();
    Actor hit = null;
    boolean found = false;
    int index = children.size - 1;
    while (!found && index >= 0) {
        Actor child = children.get(index);
        point.x = x;
        point.y = y;
        root.localToDescendantCoordinates(child, point);
        Actor childHit = root.hit(point.x, point.y, true);
        if (childHit != null && childHit.getClass().isAssignableFrom(targetClass)) {
            found = true;
            hit = childHit;
        } else {
            index--;
        }
    }
    return hit;
}
Also used : Group(com.badlogic.gdx.scenes.scene2d.Group) Actor(com.badlogic.gdx.scenes.scene2d.Actor)

Aggregations

Group (com.badlogic.gdx.scenes.scene2d.Group)14 Actor (com.badlogic.gdx.scenes.scene2d.Actor)8 Stage (com.badlogic.gdx.scenes.scene2d.Stage)5 Texture (com.badlogic.gdx.graphics.Texture)3 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)3 Layout (com.badlogic.gdx.scenes.scene2d.utils.Layout)2 Batch (com.badlogic.gdx.graphics.g2d.Batch)1 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 CpuSpriteBatch (com.badlogic.gdx.graphics.g2d.CpuSpriteBatch)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1 Vector2 (com.badlogic.gdx.math.Vector2)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)1