List of usage examples for com.badlogic.gdx.scenes.scene2d Actor localToAscendantCoordinates
public Vector2 localToAscendantCoordinates(Actor ascendant, Vector2 localCoords)
From source file:com.blastedstudios.gdxworld.util.ui.Scene2DUtils.java
License:Apache License
/** @param vec the coordinates * @param actor the actor in which coordinate system vec is given * @param other the actor into which coordinate system to convert the coordinates to * @throws IllegalArgumentException if the given actors are not in the same hierarchy */ public static void localToOtherCoordinates(Vector2 vec, Actor actor, Actor other) { Group lastParent = lastParent(actor); if (lastParent == null || lastParent != lastParent(other)) throw new IllegalArgumentException(actor + " and " + other + " are not in the same hierarchy"); actor.localToAscendantCoordinates(lastParent, vec); lastParent.localToDescendantCoordinates(other, vec); }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.scene2d.Scene2DUtils.java
License:Apache License
/** @param pos the coordinates * @param actor the actor in which coordinate system pos is given * @param other the actor into which coordinate system to convert the coordinates to * @return the given position, converted * @throws IllegalArgumentException if the given actors are not in the same hierarchy */ public static Vector2 localToOtherCoordinates(Vector2 pos, Actor actor, Actor other) { Group lastParent = lastParent(actor); if (lastParent == null || lastParent != lastParent(other)) throw new IllegalArgumentException(actor + " and " + other + " are not in the same hierarchy"); actor.localToAscendantCoordinates(lastParent, pos); lastParent.localToDescendantCoordinates(other, pos); return pos;//from w w w . j ava2s . c om }
From source file:es.eucm.ead.editor.view.builders.scene.groupeditor.GroupEditor.java
License:Open Source License
/** * @return if there was any element in the given coordinates *///from w w w . jav a 2s .c om public boolean selectLayer(float x, float y) { layersTouched.clear(); Vector2 origin = Pools.obtain(Vector2.class); Vector2 size = Pools.obtain(Vector2.class); Vector2 tmp = Pools.obtain(Vector2.class); Polygon polygon = Pools.obtain(Polygon.class); for (Actor actor : editedGroup.getChildren()) { EngineUtils.calculateBounds(actor, origin, size); int j = 0; for (int i = 0; i < 4; i++) { tmp.set(i == 0 || i == 3 ? origin.x : origin.x + size.x, i > 1 ? origin.y : origin.y + size.y); actor.localToAscendantCoordinates(this, tmp); points[j++] = tmp.x; points[j++] = tmp.y; } polygon.setVertices(points); if (polygon.contains(x, y)) { layersTouched.add(actor); } else { for (int i = 0; i < 8; i += 2) { if (nearEnough(x, y, points[i], points[i + 1])) { layersTouched.add(actor); break; } } } } Pools.free(polygon); Pools.free(tmp); Pools.free(origin); Pools.free(size); if (layersTouched.size > 0) { showLayerSelector(x, y); return true; } return false; }
From source file:es.eucm.ead.editor.view.widgets.groupeditor.GroupEditorDragListener.java
License:Open Source License
/** * @return the directly children of the current edited group that are inside * the given selection rectangle *///www.jav a 2 s.c om private Array<Actor> getActorsInside(Rectangle selection) { if (selection.width < 0) { selection.x += selection.width; selection.width = Math.abs(selection.width); } if (selection.height < 0) { selection.y += selection.height; selection.height = Math.abs(selection.height); } Vector2 o = new Vector2(); Vector2 t = new Vector2(); Vector2 n = new Vector2(); Vector2 d = new Vector2(); Array<Actor> actors = new Array<Actor>(); for (Actor a : editedGroup.getChildren()) { o.set(0, 0); t.set(a.getWidth(), 0); n.set(0, a.getHeight()); d.set(a.getWidth(), a.getHeight()); a.localToAscendantCoordinates(groupEditor, o); a.localToAscendantCoordinates(groupEditor, t); a.localToAscendantCoordinates(groupEditor, n); a.localToAscendantCoordinates(groupEditor, d); if (selection.contains(o) && selection.contains(t) && selection.contains(n) && selection.contains(d) && a.isTouchable() && a.isVisible()) { actors.add(a); } } return actors; }
From source file:es.eucm.ead.editor.view.widgets.groupeditor.Modifier.java
License:Open Source License
/** * For a given actor computes and applies the transformation of the new * group.//from www. ja va 2 s.co m * * @param actor * @param oldGroup * @param newGroup */ public void computeTransform(Actor actor, Group newGroup) { Vector2 o = tmp1.set(0, 0); Vector2 t = tmp2.set(actor.getWidth(), 0); Vector2 n = tmp3.set(0, actor.getHeight()); actor.localToAscendantCoordinates(newGroup, o); actor.localToAscendantCoordinates(newGroup, t); actor.localToAscendantCoordinates(newGroup, n); actor.setRotation(actor.getRotation() + actor.getParent().getRotation()); applyTransformation(actor, o, t, n); }
From source file:es.eucm.ead.engine.utils.EngineUtils.java
License:Open Source License
/** * For a given actor computes and applies the transformation to keep the * same screen transformation in a new group * //ww w . j a v a 2 s .co m * @param actor * @param parent */ public static void computeTransformFor(Actor actor, Group parent) { Vector2 tmp1 = Pools.obtain(Vector2.class); Vector2 tmp2 = Pools.obtain(Vector2.class); Vector2 tmp3 = Pools.obtain(Vector2.class); Vector2 tmp4 = Pools.obtain(Vector2.class); Vector2 tmp5 = Pools.obtain(Vector2.class); calculateBounds(actor, tmp4, tmp5); Vector2 o = tmp1.set(tmp4.x, tmp4.y); Vector2 t = tmp2.set(tmp4.x + tmp5.x, tmp4.y); Vector2 n = tmp3.set(tmp4.x, tmp4.y + tmp5.y); actor.localToAscendantCoordinates(parent, o); actor.localToAscendantCoordinates(parent, t); actor.localToAscendantCoordinates(parent, n); actor.setRotation(actor.getRotation() + actor.getParent().getRotation()); applyTransformation(actor, o, t, n); Pools.free(tmp1); Pools.free(tmp2); Pools.free(tmp3); Pools.free(tmp4); Pools.free(tmp5); }