List of usage examples for com.badlogic.gdx.scenes.scene2d Actor getScaleY
public float getScaleY()
From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java
License:Apache License
/** * Scale effect and Back to previous scale (SC, BTN) * *//* w w w.j a va 2 s . c om*/ public static void create_SC_BTN(Actor actor, float scaleRatioX, float scaleRatioY, float duration, final Group group, final boolean removeActor) { if (actor != null) { float originalScaleX = actor.getScaleX(); float originalScaleY = actor.getScaleY(); actor.addAction(Actions.sequence(Actions.scaleTo(scaleRatioX, scaleRatioY, duration), Actions.scaleTo(originalScaleX, originalScaleY, duration), new Action() { @Override public boolean act(float delta) { if (removeActor) { removeActor(group, actor); return false; } else { return true; } } })); } }
From source file:com.redthirddivision.astilade.render.tweens.ActorAccessor.java
License:Apache License
@Override public int getValues(Actor target, int type, float[] returnValues) { switch (type) { case TweenTypes.ALPHA: returnValues[0] = target.getColor().a; return 1; case TweenTypes.RGB: returnValues[0] = target.getColor().r; returnValues[1] = target.getColor().g; returnValues[2] = target.getColor().b; return 3; case TweenTypes.Y: returnValues[0] = target.getY(); return 1; case TweenTypes.SIZE: returnValues[0] = target.getScaleX(); returnValues[1] = target.getScaleY(); return 2; default:// w w w.java 2 s .c om assert false; return -1; } }
From source file:com.strategames.engine.tweens.ActorAccessor.java
License:Open Source License
@Override public int getValues(Actor target, int tweenType, float[] returnValues) { switch (tweenType) { case POSITION_X: returnValues[0] = target.getX(); return 1; case POSITION_Y: returnValues[0] = target.getY(); return 1; case POSITION_XY: returnValues[0] = target.getX(); returnValues[1] = target.getY(); return 2; case ALPHA://from ww w .j a va 2 s . co m returnValues[0] = target.getColor().a; return 1; case SCALE: returnValues[0] = target.getScaleX(); returnValues[1] = target.getScaleY(); return 2; case ROTATE: returnValues[0] = target.getRotation(); return 1; default: assert false; return -1; } }
From source file:com.uwsoft.editor.gdx.actors.SelectionRectangle.java
License:Apache License
public void claim(IBaseItem itm) { host = itm;/*from ww w . j ava 2s . c om*/ Actor hostAsActor = getHostAsActor(); setX(hostAsActor.getX()); setY(hostAsActor.getY()); setRotation(hostAsActor.getRotation()); setWidth(hostAsActor.getWidth() * (hostAsActor instanceof LabelItem ? 1 : hostAsActor.getScaleX())); setHeight(hostAsActor.getHeight() * (hostAsActor instanceof LabelItem ? 1 : hostAsActor.getScaleY())); }
From source file:com.uwsoft.editor.gdx.actors.SelectionRectangle.java
License:Apache License
public void update() { //setX(getHostAsActor().getX() - ((getHostAsActor().getScaleX()-1)*getHostAsActor().getWidth()/2)); //setY(getHostAsActor().getY() - ((getHostAsActor().getScaleY()-1)*getHostAsActor().getHeight()/2)); Actor hostAsActor = getHostAsActor(); setX(hostAsActor.getX());/*w w w . j av a2 s . c o m*/ setY(hostAsActor.getY()); setOriginX(hostAsActor.getOriginX()); setOriginY(hostAsActor.getOriginY()); setRotation(hostAsActor.getRotation()); setWidth(hostAsActor.getWidth() * (hostAsActor instanceof LabelItem ? 1 : hostAsActor.getScaleX())); setHeight(hostAsActor.getHeight() * (hostAsActor instanceof LabelItem ? 1 : hostAsActor.getScaleY())); positionTransformables(); }
From source file:com.uwsoft.editor.gdx.sandbox.ItemSelector.java
License:Apache License
/** * @return float Y coordinate of upper bound of current selection *///from w w w . ja va 2 s . co m public float getCurrentSelectionsHighestY() { float highestY = -Float.MAX_VALUE; for (SelectionRectangle value : currentSelection.values()) { Actor actor = value.getHostAsActor(); float maxY = Math.max(actor.getY(), actor.getY() + actor.getHeight() * actor.getScaleY()); if (maxY > highestY) { highestY = maxY; } } return highestY; }
From source file:com.uwsoft.editor.gdx.sandbox.ItemSelector.java
License:Apache License
/** * @return float Y coordinate of bottom bound of current selection *//*from w w w . j a v a2s .c o m*/ public float getCurrentSelectionsLowestY() { float lowestY = Float.MAX_VALUE; for (SelectionRectangle value : currentSelection.values()) { Actor actor = value.getHostAsActor(); float minY = Math.min(actor.getY(), actor.getY() + actor.getHeight() * actor.getScaleY()); if (minY < lowestY) { lowestY = minY; } } return lowestY; }
From source file:com.uwsoft.editor.gdx.sandbox.ItemSelector.java
License:Apache License
public void alignSelectionsByY(float y, boolean ignoreSelfHeight) { int ratio = ignoreSelfHeight ? 0 : 1; for (SelectionRectangle value : currentSelection.values()) { Actor actor = value.getHostAsActor(); //actor.setY(y - ratio * actor.getHeight()); if (actor.getScaleY() < 0) { actor.setY(y - (ratio + actor.getScaleY()) * actor.getHeight()); } else {/*from w w w.j a v a 2 s .c o m*/ actor.setY(y - ratio * actor.getHeight()); } value.setY(actor.getY()); } }
From source file:es.eucm.ead.editor.control.actions.model.scene.ActorTransformToEntity.java
License:Open Source License
@Override public CompositeCommand perform(Object... args) { Actor actor = (Actor) args[0]; ModelEntity modelEntity = Q.getModelEntity(actor); if (modelEntity == null) { return null; }/*from www . j a va 2s . com*/ CompositeCommand compositeCommand = super.perform(args); if (actor.getOriginX() != modelEntity.getOriginX()) { compositeCommand.addCommand(new FieldCommand(modelEntity, FieldName.ORIGIN_X, actor.getOriginX())); } if (actor.getOriginY() != modelEntity.getOriginY()) { compositeCommand.addCommand(new FieldCommand(modelEntity, FieldName.ORIGIN_Y, actor.getOriginY())); } if (actor.getRotation() != modelEntity.getRotation()) { compositeCommand.addCommand(new FieldCommand(modelEntity, FieldName.ROTATION, actor.getRotation())); } if (actor.getScaleX() != modelEntity.getScaleX()) { compositeCommand.addCommand(new FieldCommand(modelEntity, FieldName.SCALE_X, actor.getScaleX())); } if (actor.getScaleY() != modelEntity.getScaleY()) { compositeCommand.addCommand(new FieldCommand(modelEntity, FieldName.SCALE_Y, actor.getScaleY())); } return compositeCommand; }
From source file:es.eucm.ead.editor.view.widgets.groupeditor.Modifier.java
License:Open Source License
/** * Applies the current transformation represented by the handles to given * actor// w w w. ja va2 s . co m */ public void applyTransformation(Actor influencedActor, Vector2 origin, Vector2 tangent, Vector2 normal) { /* * We are going to calculate the affine transformation for the actor to * fit the bounds represented by the handles. The affine transformation * is defined as follows: */ // |a b tx| // |c d ty|=|Translation Matrix| x |Scale Matrix| x |Rotation // Matrix| // |0 0 1 | /* * More info about affine transformations: * https://people.gnome.org/~mathieu * /libart/libart-affine-transformation-matrices.html, To obtain the * matrix, we want to resolve the following equation system: */ // | a b tx| |0| |o.x| // | c d ty|*|0|=|o.y| // | 0 0 1 | |1| | 1 | // // | a b tx| |w| |t.x| // | c d ty|*|0|=|t.y| // | 0 0 1 | |1| | 1 | // // | a b tx| |0| |n.x| // | c d ty|*|h|=|n.y| // | 0 0 1 | |1| | 1 | /* * where o is handles[0] (origin), t is handles[2] (tangent) and n is * handles[6] (normal), w is actor.getWidth() and h is * actor.getHeight(). * * This matrix defines that the 3 points defining actor bounds are * transformed to the 3 points defining modifier bounds. E.g., we want * that actor origin (0,0) is transformed to (handles[0].x, * handles[0].y), and that is expressed in the first equation. * * Resolving these equations is obtained: */ // a = (t.x - o.y) / w // b = (t.y - o.y) / w // c = (n.x - o.x) / h // d = (n.y - o.y) / h /* * Values for translation, scale and rotation contained by the matrix * can be obtained directly making operations over a, b, c and d: */ // tx = o.x // ty = o.y // sx = sqrt(a^2+b^2) // sy = sqrt(c^2+d^2) // rotation = atan(c/d) // or // rotation = atan(-b/a) /* * Rotation can give two different values (this happens when there is * more than one way of obtaining the same transformation). To avoid * that, we ignore the rotation to obtain the final values. */ Vector2 o = tmp1.set(origin.x, origin.y); Vector2 t = tmp2.set(tangent.x, tangent.y); Vector2 n = tmp3.set(normal.x, normal.y); Vector2 vt = tmp4.set(t).sub(o); Vector2 vn = tmp5.set(n).sub(o); // Ignore rotation float rotation = influencedActor.getRotation(); vt.rotate(-rotation); vn.rotate(-rotation); t.set(vt).add(o); n.set(vn).add(o); float a = (t.x - o.x) / influencedActor.getWidth(); float c = (t.y - o.y) / influencedActor.getWidth(); float b = (n.x - o.x) / influencedActor.getHeight(); float d = (n.y - o.y) / influencedActor.getHeight(); // Math.sqrt gives a positive value, but it also have a negatives. // The // signum is calculated computing the current rotation float signumX = vt.angle() > 90.0f && vt.angle() < 270.0f ? -1.0f : 1.0f; float signumY = vn.angle() > 180.0f ? -1.0f : 1.0f; float scaleX = (float) Math.sqrt(a * a + b * b) * signumX; float scaleY = (float) Math.sqrt(c * c + d * d) * signumY; influencedActor.setScale(scaleX, scaleY); /* * To obtain the correct translation value we need to subtract the * amount of translation due to the origin. */ tmpMatrix.setToTranslation(influencedActor.getOriginX(), influencedActor.getOriginY()); tmpMatrix.rotate(influencedActor.getRotation()); tmpMatrix.scale(influencedActor.getScaleX(), influencedActor.getScaleY()); tmpMatrix.translate(-influencedActor.getOriginX(), -influencedActor.getOriginY()); /* * Now, the matrix has how much translation is due to the origin * involved in the rotation and scaling operations */ float x = o.x - tmpMatrix.getValues()[Matrix3.M02]; float y = o.y - tmpMatrix.getValues()[Matrix3.M12]; influencedActor.setPosition(x, y); }