private void focusChanged (FocusEvent event) { Stage stage = getStage(); if (isModal && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this) && !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus))) event.cancel(); } } };
Group group = new Group(); group.setX((float)Math.random() * (stage.getWidth() - NUM_SPRITES * (32 + SPACING))); group.setY((float)Math.random() * (stage.getHeight() - NUM_SPRITES * (32 + SPACING))); group.setOrigin(loc, loc); sprites.add(shapeActor); Group shapeGroup = new Group(); shapeGroup.setBounds(300, 300, 300, 300); shapeGroup.setOrigin(50, 75); shapeGroup.setTouchable(Touchable.childrenOnly); shapeGroup.addActor(shapeActor); stage.addActor(shapeGroup);
/** If this method is overridden, the super method or {@link #validate()} should be called to ensure the widget group is laid * out. */ public void draw (Batch batch, float parentAlpha) { validate(); super.draw(batch, parentAlpha); } }
/** Creates a stage with the specified viewport and batch. This can be used to avoid creating a new batch (which can be * somewhat slow) if multiple stages are used during an application's life time. * @param batch Will not be disposed if {@link #dispose()} is called, handle disposal yourself. */ public Stage (Viewport viewport, Batch batch) { if (viewport == null) throw new IllegalArgumentException("viewport cannot be null."); if (batch == null) throw new IllegalArgumentException("batch cannot be null."); this.viewport = viewport; this.batch = batch; root = new Group(); root.setStage(this); viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); }
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; }
stage1.getCamera().position.set(100, 100, 0); Group group = new Group(); group.setRotation(10); group.setScale(1.2f); stage1.addActor(group); actor.setScale(2f); actor.addAction(forever(rotateBy(360, 8f))); group.addActor(actor); group.debugAll();
/** Adds an actor to the root of the stage. * @see Group#addActor(Actor) */ public void addActor (Actor actor) { root.addActor(actor); }
public void validate () { if (!layoutEnabled) return; Group parent = getParent(); if (fillParent && parent != null) { float parentWidth, parentHeight; Stage stage = getStage(); if (stage != null && parent == stage.getRoot()) { parentWidth = stage.getWidth(); parentHeight = stage.getHeight(); } else { parentWidth = parent.getWidth(); parentHeight = parent.getHeight(); } setSize(parentWidth, parentHeight); } if (!needsLayout) return; needsLayout = false; layout(); }
@Override public float[] getPositionAndSizeGui(String name) { IGui gui = GaiaSky.instance.mainGui; Actor actor = gui.getGuiStage().getRoot().findActor(name); if (actor != null) { float x = actor.getX(); float y = actor.getY(); // x and y relative to parent, so we need to add coordinates of // parents up to top Group parent = actor.getParent(); while (parent != null) { x += parent.getX(); y += parent.getY(); parent = parent.getParent(); } return new float[] { x, y, actor.getWidth(), actor.getHeight() }; } else { return null; } }
@Override public Actor parse(CocoCreatorUIEditor editor, final ObjectData widget) { Group group = new Group(); for (AANode cNode : widget._components) { Actor childrenActor = editor.parseWidget(group, (ObjectData) cNode); if (childrenActor == null) { continue; } group.addActor(childrenActor); } return group; }
private void updateGroupProperties( ExternalGroupModel model, Group group){ group.setName( model.getName()); model.setWidth( group.getWidth()); model.setHeight( group.getHeight()); // For example .. <FriendsPanel > in top xml and its implementation's root group (FriendsPanel.xml file's) // should both be visible=true in order to set whole group visible, if at least one of them set to false // whole group will be invisible. group.setVisible(model.isVisible() && group.isVisible()); Vector2 screenPos; if (model.getScreenAlignmentSupport() == null) { screenPos = calculateScreenPosition(model.getScreenAlignment(), model); } else { screenPos = calculateScreenPosition(model.getScreenAlignment(), model.getScreenAlignmentSupport(), model); } if (screenPos != null) { group.setPosition(screenPos.x, screenPos.y); } else { float positionMultiplier = resolutionHelper.getPositionMultiplier(); group.setPosition(model.getX() * positionMultiplier, model.getY() * positionMultiplier); } setScaleProperty(model, group); } }
/** Returns the first actor found with the specified name. Note this recursively compares the name of every actor in the * group. */ public <T extends Actor> T findActor (String name) { Array<Actor> children = this.children; for (int i = 0, n = children.size; i < n; i++) if (name.equals(children.get(i).getName())) return (T)children.get(i); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i); if (child instanceof Group) { Actor actor = ((Group)child).findActor(name); if (actor != null) return (T)actor; } } return null; }
/** @return May be null. */ private TextField findNextTextField (Array<Actor> actors, TextField best, Vector2 bestCoords, Vector2 currentCoords, boolean up) { for (int i = 0, n = actors.size; i < n; i++) { Actor actor = actors.get(i); if (actor instanceof TextField) { if (actor == this) continue; TextField textField = (TextField)actor; if (textField.isDisabled() || !textField.focusTraversal || !textField.ancestorsVisible()) continue; Vector2 actorCoords = actor.getParent().localToStageCoordinates(tmp3.set(actor.getX(), actor.getY())); boolean below = actorCoords.y != currentCoords.y && (actorCoords.y < currentCoords.y ^ up); boolean right = actorCoords.y == currentCoords.y && (actorCoords.x > currentCoords.x ^ up); if (!below && !right) continue; boolean better = best == null || (actorCoords.y != bestCoords.y && (actorCoords.y > bestCoords.y ^ up)); if (!better) better = actorCoords.y == bestCoords.y && (actorCoords.x < bestCoords.x ^ up); if (better) { best = (TextField)actor; bestCoords.set(actorCoords); } } else if (actor instanceof Group) best = findNextTextField(((Group)actor).getChildren(), best, bestCoords, currentCoords, up); } return best; }
@Override public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) { if (toolsButton.isChecked()) { scnWidget.getParent().addActor(toolsWindow); toolsWindow.setPosition(getScnWidget().getX() + 5, getScnWidget().getY() + 5); toolsWindow.invalidate(); } else { scnWidget.getParent().removeActor(toolsWindow); } } });
@Override public void onLoadedResourcesCompleted() { final TextureAtlas bgAtlas = Engine.resource("bgAtlas", TextureAtlas.class); rbg = new ParallaxGroup(480, 320, new Vector2(50, 100)); rbg.addActor(new Image(new AdvanceSprite(bgAtlas.findRegion("bg")))); rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("cloud"))), new Vector2(0.5f, 0), new Vector2(0, 1000), new Vector2(0, 70))); rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("front"))), new Vector2(1f, 0), new Vector2(0, 1000), new Vector2())); rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("dock-tree"))), new Vector2(1f, 0), new Vector2(1000, 1000), new Vector2())); rbg.addAction(Actions.forever(Actions.sequence( ParallaxGroupSpeedToAction.obtain(1000, 300, 1), ParallaxGroupSpeedToAction.obtain(50, 300, 2), Actions.scaleTo(2, 2, 0.5f), Actions.scaleTo(1, 1, 1.5f) ))); final SceneStage stage = new SceneStage(); final Group group = new Group(); group.setScale(Engine.getWidth() / 480f); group.addActor(rbg); stage.addActor(group); Engine.setMainScene(stage); } }
console = new Group(); console.setVisible(false); .click(() -> { buuleable(false); console.setVisible(true); }); pane.setPosition(0, 45); console.addActor(pane); console.setVisible(false); buuleable(true); });