List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setRotation
public void setRotation(float degrees)
From source file:com.quadbits.gdxhelper.controllers.LinearTrajectoryController.java
License:Apache License
protected void enterScene(Actor actor) { outOfScene = false;//ww w. ja v a 2s . c om currentOutOfSceneTimeMillis = 0; actor.setVisible(true); currentInterpolationValue = 0; boolean reverse = false; if (reversable) { reverse = random.nextBoolean(); } // choose source and target points if (!reverse) { chooseRandomSourceAndTarget(sourceX1, sourceY1, sourceX2, sourceY2, targetX1, targetY1, targetX2, targetY2); if (actor instanceof FlippableActor) { ((FlippableActor) actor).setFlipX(false); } } else { chooseRandomSourceAndTarget(targetX1, targetY1, targetX2, targetY2, sourceX1, sourceY1, sourceX2, sourceY2); if (actor instanceof FlippableActor) { ((FlippableActor) actor).setFlipX(true); } } // calculate interpolation step tmpVector.set(currentTarget); tmpVector.sub(currentSource); float speed = avgSpeedMillis + ((float) random.nextGaussian()) * stdSpeedMillis; interpolationStep = speed / tmpVector.len(); // rotate actor (if requested) if (adjustActorRotation) { float angle = tmpVector.angle(); if (angle > 90 && angle <= 180) { angle = -(180 - angle); } if (angle > 180 && angle <= 270) { angle = angle - 180; } actor.setRotation(angle); } }
From source file:com.quadbits.gdxhelper.controllers.PeriodicRotationController.java
License:Apache License
@Override public void control(Actor actor, float deltaSeconds) { long deltaMillis = (long) (deltaSeconds * 1000); timePeriodManager.update(deltaMillis); float angle;// w w w . j a v a 2s. c o m float normalizedValue; int subPeriod = timePeriodManager.getCurrentSubPeriod(); // Rotate up if (subPeriod == rotateUpSubPeriod) { normalizedValue = timePeriodManager.getNormalizedCurrentSubPeriodTime(); Interpolation interpolation = Interpolation.linear; if (this.interpolation != null) { interpolation = this.interpolation; } angle = interpolation.apply(minAngle, maxAngle, normalizedValue); } // Stall up else if (subPeriod == stallUpSubPeriod) { angle = maxAngle; } // Rotate down else if (subPeriod == rotateDownSubPeriod) { normalizedValue = timePeriodManager.getNormalizedCurrentSubPeriodTime(); Interpolation interpolation = Interpolation.linear; if (this.interpolation != null) { interpolation = this.interpolation; } angle = interpolation.apply(maxAngle, minAngle, normalizedValue); } // Stall up else { angle = minAngle; } actor.setRotation(angle); }
From source file:com.quadbits.gdxhelper.controllers.RotateOnScrollController.java
License:Apache License
@Override public void control(Actor actor, float deltaSeconds) { // scroll is in the [0, 1] range; actor's rotation angle should be set in the range // [minAngle, maxAngle] actor.setRotation(minAngle + scroll * (maxAngle - minAngle)); }
From source file:com.strategames.engine.tweens.ActorAccessor.java
License:Open Source License
@Override public void setValues(Actor target, int tweenType, float[] newValues) { switch (tweenType) { case POSITION_X: target.setX(newValues[0]);/*from ww w .ja v a2s. co m*/ break; case POSITION_Y: target.setY(newValues[0]); break; case POSITION_XY: target.setX(newValues[0]); target.setY(newValues[1]); break; case ALPHA: target.getColor().a = newValues[0]; break; case SCALE: target.setScaleX(newValues[0]); target.setScaleY(newValues[1]); break; case ROTATE: target.setRotation(newValues[0]); default: assert false; break; } }
From source file:es.eucm.ead.editor.view.widgets.groupeditor.Grouper.java
License:Open Source License
/** * @param group/*from www . j a v a 2 s . c o m*/ * an empty group to be the parent * @return the group with the current selection */ public Group createGroup(Group group) { // New group has the same transformation as this group.setBounds(getX(), getY(), getWidth(), getHeight()); group.setOrigin(getOriginX(), getOriginY()); group.setRotation(getRotation()); group.setScale(getScaleX(), getScaleY()); // Each children in the group must be contained by the new group Array<Actor> children = getChildren(); children.sort(new Comparator<Actor>() { @Override public int compare(Actor actor, Actor actor2) { return ((SelectionGhost) actor).getRepresentedActor().getZIndex() - ((SelectionGhost) actor2).getRepresentedActor().getZIndex(); } }); for (Actor actor : children) { SelectionGhost ghost = (SelectionGhost) actor; Actor representedActor = ghost.getRepresentedActor(); representedActor.setPosition(ghost.getX(), ghost.getY()); representedActor.setRotation(ghost.getRotation()); representedActor.setScale(ghost.getScaleX(), ghost.getScaleY()); group.addActor(representedActor); } return group; }
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 ww w . j a v a 2 s . c o 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 * //w ww.j ava 2 s.com * @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); }
From source file:mobi.shad.s3lib.gui.GuiUtil.java
License:Apache License
/** * @param source//from w w w . j a va 2 s . c o m * @param destination */ public static void copyActor(Actor source, Actor destination) { destination.setBounds(source.getX(), source.getY(), source.getWidth(), source.getHeight()); destination.setColor(source.getColor()); destination.setName(source.getName()); destination.setOrigin(source.getOriginX(), source.getOriginY()); destination.setRotation(source.getRotation()); destination.setScale(source.getScaleX(), source.getScaleY()); destination.setTouchable(source.getTouchable()); destination.setUserObject(source.getUserObject()); destination.setVisible(source.isVisible()); destination.setZIndex(source.getZIndex()); destination.getStage(); }
From source file:net.dermetfan.gdx.scenes.scene2d.ui.CircularGroup.java
License:Apache License
@Override public void layout() { float prefWidthUnderflow = shrinkChildren ? Math.max(0, getPrefWidth() - getWidth()) / 2 : 0, prefHeightUnderflow = shrinkChildren ? Math.max(0, getPrefHeight() - getHeight()) / 2 : 0; SnapshotArray<Actor> children = getChildren(); for (int index = 0; index < children.size; index++) { Actor child = children.get(index); // get dimensions and resize float width, height; if (child instanceof Layout) { Layout childLayout = (Layout) child; width = childLayout.getPrefWidth() - prefWidthUnderflow; width = Math.max(width, childLayout.getMinWidth()); if (childLayout.getMaxWidth() != 0) width = Math.min(width, childLayout.getMaxWidth()); height = childLayout.getPrefHeight() - prefHeightUnderflow; height = Math.max(height, childLayout.getMinHeight()); if (childLayout.getMaxHeight() != 0) height = Math.min(height, childLayout.getMaxHeight()); child.setSize(width, height); childLayout.validate();/*from w ww . j av a 2s. c o m*/ } else { width = child.getWidth(); height = child.getHeight(); } float angle = fullAngle / (children.size - (virtualChildEnabled ? 0 : 1)) * index; angle += angleOffset; angle = modifier.angle(angle, child, index, children.size, this); float rotation = modifier.rotation(angle, child, index, children.size, this); tmp.set(modifier.anchorOffset(tmp.setZero(), child, index, children.size, this)); tmp.rotate(angle); float offsetX = tmp.x, offsetY = tmp.y; tmp.set(modifier.localAnchor(tmp.set(width, height / 2), child, index, children.size, this)); float localAnchorX = tmp.x, localAnchorY = tmp.y; child.setOrigin(localAnchorX, localAnchorY); child.setRotation(rotation); child.setPosition(getWidth() / 2 + offsetX - localAnchorX, getHeight() / 2 + offsetY - localAnchorY); } }
From source file:net.mwplay.cocostudio.ui.BaseWidgetParser.java
License:Apache License
/** * common attribute parser//from w w w . j a v a 2 s. c o m * according cocstudio ui setting properties of the configuration file * * @param editor * @param widget * @param parent * @param actor * @return */ public Actor commonParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) { this.editor = editor; actor.setName(widget.getName()); actor.setSize(widget.getSize().getX(), widget.getSize().getY()); // set origin if (widget.getAnchorPoint() != null) { actor.setOrigin(widget.getAnchorPoint().getScaleX() * actor.getWidth(), widget.getAnchorPoint().getScaleY() * actor.getHeight()); } //?Postion if (widget.getPosition() != null) { actor.setPosition(widget.getPosition().getX() - actor.getOriginX(), widget.getPosition().getY() - actor.getOriginY()); } // CocoStudioScaleX,ScaleY //?Scale if (widget.getScale() != null) { actor.setScale(widget.getScale().getScaleX(), widget.getScale().getScaleY()); } if (widget.getRotation() != 0) {// CocoStudio ?,?. actor.setRotation(360 - widget.getRotation() % 360); } // if (widget.getRotationSkewX() != 0 && widget.getRotationSkewX() == widget.getRotationSkewY()) { actor.setRotation(360 - widget.getRotationSkewX() % 360); } // ?? actor.setVisible(widget.isVisibleForFrame()); Color color = editor.getColor(widget.getCColor(), widget.getAlpha()); actor.setColor(color); actor.setTouchable(deduceTouchable(actor, widget)); // callback addCallback(actor, widget); // callback addActor(editor, actor, widget); if (widget.getChildren() == null || widget.getChildren().size() == 0) { //Action parseAction(actor, widget); return actor; } return null; }