List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setOrigin
public void setOrigin(float originX, float originY)
From source file:com.bagon.matchteam.mtx.utils.UtilsOrigin.java
License:Apache License
private static void setOrigin(Actor actor, Origin origin) { switch (origin) { case CENTER:/*from ww w.j av a2s .c o m*/ actor.setOrigin(actor.getWidth() / 2.0f, actor.getHeight() / 2.0f); break; case TOP_LEFT: actor.setOrigin(0.0f, actor.getHeight()); break; case TOP_RIGHT: actor.setOrigin(actor.getWidth(), actor.getHeight()); break; case BOTTOM_LEFT: actor.setOrigin(0.0f, 0.0f); break; case BOTTOM_RIGHT: actor.setOrigin(actor.getWidth(), 0.0f); break; case LEFT_CENTER: actor.setOrigin(0.0f, actor.getHeight() / 2.0f); break; case TOP_CENTER: actor.setOrigin(actor.getWidth() / 2.0f, actor.getHeight()); break; case BOTTOM_CENTER: actor.setOrigin(actor.getWidth() / 2.0f, 0.0f); break; case RIGHT_CENTER: actor.setOrigin(actor.getWidth(), actor.getHeight() / 2.0f); break; default: actor.setOrigin(actor.getOriginX(), actor.getOriginY()); break; } }
From source file:com.sawan.mathattack.utils.UtilsOrigin.java
License:Open Source License
/** * Sets the origin.//from w w w. ja v a2 s . c om * * @param actor the actor * @param origin the origin */ private static void setOrigin(Actor actor, Origin origin) { switch (origin) { case CENTER: actor.setOrigin(actor.getWidth() / 2.0f, actor.getHeight() / 2.0f); break; case TOP_LEFT: actor.setOrigin(0.0f, actor.getHeight()); break; case TOP_RIGHT: actor.setOrigin(actor.getWidth(), actor.getHeight()); break; case BOTTOM_LEFT: actor.setOrigin(0.0f, 0.0f); break; case BOTTOM_RIGHT: actor.setOrigin(actor.getWidth(), 0.0f); break; case LEFT_CENTER: actor.setOrigin(0.0f, actor.getHeight() / 2.0f); break; case TOP_CENTER: actor.setOrigin(actor.getWidth() / 2.0f, actor.getHeight()); break; case BOTTOM_CENTER: actor.setOrigin(actor.getWidth() / 2.0f, 0.0f); break; case RIGHT_CENTER: actor.setOrigin(actor.getWidth(), actor.getHeight() / 2.0f); break; default: actor.setOrigin(actor.getOriginX(), actor.getOriginY()); break; } }
From source file:com.strategames.catchdastars.screens.game.GameCompleteScreen.java
License:Open Source License
@Override protected Timeline showAnimation() { final Timeline timeline = Timeline.createSequence(); timeline.beginParallel();/* w w w . ja v a2 s . co m*/ Stage stage = getStageActors(); Array<Actor> balloons = new Array<Actor>(); Array<Actor> actors = stage.getActors(); for (int i = 0; i < actors.size; i++) { Actor actor = actors.get(i); if (actor instanceof Balloon) { balloons.add(actor); actor.setOrigin(actor.getWidth() / 2f, actor.getHeight() / 2f); timeline.push(createBlowUpAnimation(stage, actor)); } } timeline.end(); Tween flashTween = Tween.from(this.filter, ActorAccessor.ALPHA, 1f).target(1f) .ease(TweenEquations.easeInExpo).setCallbackTriggers(TweenCallback.END) .setCallback(new TweenCallback() { @Override public void onEvent(int arg0, BaseTween<?> arg1) { if (arg0 == TweenCallback.END) { GameCompleteDialog dialog = new GameCompleteDialog(getStageUIActors(), getSkin()); dialog.setOnClickListener(new OnClickListener() { @Override public void onClick(Dialog dialog, int which) { getGameEngine().showMainMenu(); } }); dialog.create(); dialog.show(); } } }); timeline.push(flashTween); //Make sure balloons are drawn last by removing //and re-adding balloons to stage for (int i = 0; i < balloons.size; i++) { Actor actor = balloons.get(i); actor.remove(); stage.addActor(actor); } return timeline; }
From source file:io.piotrjastrzebski.sfg.screen.GameScreen.java
License:Open Source License
private void centreOrigin(Actor actor) { actor.setOrigin(actor.getWidth() / 2, actor.getHeight() / 2); }
From source file:mobi.shad.s3lib.gui.GuiUtil.java
License:Apache License
/** * @param source//from w ww . j a va 2s.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();/*ww w .jav a 2 s. c om*/ } 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 va2s . c om * 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; }