protected void update (float percent) { target.setPosition(startX + (endX - startX) * percent, startY + (endY - startY) * percent, alignment); }
protected void update (float percent) { target.setPosition(startX + (endX - startX) * percent, startY + (endY - startY) * percent, alignment); }
widget.setPosition(x, y);
widget.setPosition(x, y);
private float layout (Array<Node> nodes, float indent, float y, float plusMinusWidth) { float ySpacing = this.ySpacing; float spacing = iconSpacingLeft + iconSpacingRight; for (int i = 0, n = nodes.size; i < n; i++) { Node node = nodes.get(i); float x = indent + plusMinusWidth; if (node.icon != null) x += spacing + node.icon.getMinWidth(); if (node.actor instanceof Layout) ((Layout)node.actor).pack(); y -= node.getHeight(); node.actor.setPosition(x, y); y -= ySpacing; if (node.expanded) y = layout(node.children, indent + indentSpacing, y, plusMinusWidth); } return y; }
private float layout (Array<Node> nodes, float indent, float y, float plusMinusWidth) { float ySpacing = this.ySpacing; float spacing = iconSpacingLeft + iconSpacingRight; for (int i = 0, n = nodes.size; i < n; i++) { Node node = nodes.get(i); float x = indent + plusMinusWidth; if (node.icon != null) x += spacing + node.icon.getMinWidth(); if (node.actor instanceof Layout) ((Layout)node.actor).pack(); y -= node.getHeight(); node.actor.setPosition(x, y); y -= ySpacing; if (node.expanded) y = layout(node.children, indent + indentSpacing, y, plusMinusWidth); } return y; }
private Group createActorGroup (TextureRegionDrawable bob) { Actor main = new DrawableActor(bob); main.setPosition(0, 0, Align.center); Actor hat = new DrawableActor(bob) { @Override public void act (float delta) { rotateBy(delta * -300); } }; hat.setOrigin(Align.center); hat.setScale(0.5f); hat.setPosition(0, 21, Align.center); Group group = new Group() { @Override public void act (float delta) { rotateBy(delta * 120); setScale(0.9f + 0.2f * MathUtils.cos(MathUtils.degreesToRadians * getRotation())); super.act(delta); } }; group.addActor(main); group.addActor(hat) ; // group.setTransform(false); float margin = 35; float x = MathUtils.random(margin, stage.getWidth() - margin); float y = MathUtils.random(margin, stage.getHeight() - margin); group.setPosition(x, y); group.setRotation(MathUtils.random(0, 360)); return group; }
if (actorY + actor.getHeight() > stage.getHeight()) actorY = stage.getHeight() - actor.getHeight(); actor.setPosition(actorX, actorY);
if (actorY + actor.getHeight() > stage.getHeight()) actorY = stage.getHeight() - actor.getHeight(); actor.setPosition(actorX, actorY);
public GdxQuery position(float x, float y){ for(Actor actor:list()) actor.setPosition((int)x, (int)y); return this; }
/** * Draws one AnimatedEntity, specifically the Actor it contains. Batch must be between start() and end() * @param batch Must have start() called already but not stop() yet during this frame. * @param parentAlpha This can be assumed to be 1.0f if you don't know it * @param ac The Actor to draw; the position to draw ac is modified and reset based on some fields of this object */ public void drawActor(Batch batch, float parentAlpha, Actor ac) { float prevX = ac.getX(), prevY = ac.getY(); ac.setPosition(prevX - gridOffsetX * cellWidth, prevY + gridOffsetY * cellHeight); ac.draw(batch, parentAlpha); ac.setPosition(prevX, prevY); }
public void fixPosition(AnimatedEntity ae) { ae.actor.setPosition(adjustX(ae.gridX, ae.doubleWidth), adjustY(ae.gridY)); } public void fixPositions()
public UI<T> setPosition(Actor actor, int align) { t.setPosition(actor.getX(), actor.getY(), align); return this; }
private void moveActor(float x, float y, int align) { if (nowActor == null) return; nowActor.setPosition(x, y, align); msg(nowActor, allDatas.get(nowActor), "X:" + (int) nowActor.getX() + ",Y:" + (int) nowActor.getY()); }
@Override public void draw (final Batch batch, final float parentAlpha) { if (actor != null) { LAST_POSITION.set(actor.getX(), actor.getY()); actor.setPosition(getX(), getY()); actor.draw(batch, getColor().a * parentAlpha); actor.setPosition(LAST_POSITION.x, LAST_POSITION.y); } } }
@Override public void layout() { super.layout(); if (actor != null) { actor.setPosition(0f, 0f); actor.setSize(getWidth(), getHeight()); } }
public void fixPositions() { for (int i = 0; i < animatedEntities.size(); i++) { AnimatedEntity ae = animatedEntities.getAt(i); ae.actor.setPosition(adjustX(ae.gridX, ae.doubleWidth), adjustY(ae.gridY)); } }
public AnimatedEntity directionMarker(int x, int y, boolean doubleWidth, Color color) { Actor a = textFactory.makeDirectionMarker(color); a.setName("^"); a.setPosition(adjustX(x, doubleWidth), adjustY(y)); AnimatedEntity ae = new AnimatedEntity(a, x, y, doubleWidth); animatedEntities.add(ae); return ae; } /**
public AnimatedEntity directionMarker(int x, int y, boolean doubleWidth, Color color) { Actor a = textFactory.makeDirectionMarker(color); a.setName("^"); a.setPosition(adjustX(x, doubleWidth), adjustY(y)); AnimatedEntity ae = new AnimatedEntity(a, x, y, doubleWidth); animatedEntities.add(ae); return ae; }
public boolean replaceChildWith(Actor actorToRemove, Actor actorToInsert) { int index = getChildren().indexOf(actorToRemove, false); if (index == -1) return false; actorToInsert.setPosition(actorToRemove.getX(), actorToRemove.getY()); actorToInsert.setUserObject(actorToRemove.getUserObject()); removeActor(actorToRemove, false); addActorAt(index, actorToInsert); return true; } }