List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setSize
public void setSize(float width, float height)
From source file:ateamproject.kezuino.com.github.render.screens.GameScreen.java
@Override public void render(float delta) { // Render Game and UI. super.render(delta); switch (getSession().getState()) { case GameOverHighscoreReached: PacketKick packet = new PacketKick(PacketKick.KickReasonType.GAME, null, null); Client.getInstance().send(packet); game.setScreen(new HighscoreScreen(game, true)); break;//from w w w. ja va 2 s . c om case GameOver: //getSession().end(); game.setScreen(new GameOverScreen(game, getSession().getScore())); break; case Completed: Actor btnContinue = new TextButton("Doorgaan", skin); Actor lblEndGameText = new Label("Je score is:", skin); Actor lblScore = new Label(Integer.toString(getSession().getScore().valueOf()), skin); btnContinue.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { btnContinue.remove(); lblEndGameText.remove(); lblScore.remove(); start(getSession().getScore()); Client.getInstance().send(new PacketLaunchGame(false, BaseScreen.getSession().getLevel() + 1, BaseScreen.getSession().getScore().valueOf(), Client.getInstance().getId())); } }); lblEndGameText.setPosition(stage.getWidth() / 2 - lblEndGameText.getWidth() / 2, stage.getHeight() - 80); lblScore.setPosition(stage.getWidth() / 2 - lblScore.getWidth() / 2, stage.getHeight() - 100); btnContinue.setSize(200, 40); btnContinue.setPosition(stage.getWidth() / 2 - btnContinue.getWidth() / 2, stage.getHeight() / 4 - btnContinue.getHeight() / 2); if (Client.getInstance().isHost()) { stage.addActor(btnContinue); } stage.addActor(lblEndGameText); stage.addActor(lblScore); getSession().end(); break; } }
From source file:com.bagon.matchteam.mtx.utils.UtilsActor.java
License:Apache License
/** * Set size for multiple actors at once/*from w ww . ja va2 s .co m*/ * */ public static void setSize(float w, float h, Actor... actors) { for (Actor a : actors) { a.setSize(w, h); } }
From source file:com.centergame.starttrack.graphics.starttrack_widgets.TeamGradeWidget.java
public void init() { setBackgroundColor(StartTrackApp.ColorPallete.BACK); setWidth(Gdx.graphics.getWidth());//from w ww .ja v a 2s . c o m layout.paddingLeft = mp; layout.paddingTop = mp; layout.paddingBottom = sp; layout.addActor( new Text("???? ??", StartTrackApp.getResources().getLabelStyle("header"))); if (StartTrackApp.getState().game.team_grade_required) { com.centergame.starttrack.graphics.starttrack_widgets.base.RadioGroup rg = new com.centergame.starttrack.graphics.starttrack_widgets.base.RadioGroup( 0, 3, data); rg.paddingLeft = sp / 2; rg.paddingRight = sp / 2; rg.paddingBottom = mp; rg.paddingTop = mp; rg.setWidth(getWidth() - layout.paddingLeft - layout.paddingRight); rg.layout(); layout.addActor(rg); Actor a = new IdpColorPixmap(StartTrackApp.ColorPallete.ELEMENT_BORDER).buildActor(); a.setSize(getWidth() - 2 * sp, App.dp2px(2)); Group g = new Group(); g.setWidth(getWidth() - layout.paddingLeft - layout.paddingRight); g.setHeight(a.getHeight()); g.addActor(a); a.setX(g.getWidth() / 2 - a.getWidth() / 2); layout.addActor(g); } else { Text note = new Text("? ??".toUpperCase(), StartTrackApp.getResources().getLabelStyle("number")); note.getStyle().fontColor = Color.valueOf("999999"); layout.setGap(App.dp2px(18)); note.setWidth(Gdx.graphics.getWidth() - layout.paddingRight - layout.paddingLeft); note.setAlignment(Align.center); layout.addActor(note); } Text participantsListTitle = new Text("? ??", StartTrackApp.getResources().getLabelStyle("header")); participantsListTitle.setPosition(lp, layout.getY() + layout.getHeight() + mp); layout.addActor(participantsListTitle); }
From source file:es.eucm.ead.editor.control.Views.java
License:Open Source License
/** * Show the given modal in the given coordinates */// w ww .j av a2 s .co m public void showModal(Actor modal, float x, float y) { if (currentModal != null) { currentModal.clearActions(); hideModalsContainer.run(); } modalsContainer.addActor(modal); if (modal instanceof Layout) { ((Layout) modal).pack(); } modal.setSize(Math.min(modalsContainer.getWidth(), AbstractWidget.getPrefWidth(modal)), Math.min(modalsContainer.getHeight(), AbstractWidget.getPrefHeight(modal))); modal.setPosition(Math.max(0, Math.min(x, modalsContainer.getWidth() - modal.getWidth())), Math.min(Math.max(0, y), modalsContainer.getHeight() - modal.getHeight())); modalsContainer.setTouchable(Touchable.enabled); if (modal instanceof Modal) { ((Modal) modal).show(this); } setKeyboardFocus(modal); setScrollFocus(modal); currentModal = modal; }
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 a v a 2s .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//w w w. j a v a 2s .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; }