List of usage examples for com.badlogic.gdx.scenes.scene2d Actor getHeight
public float getHeight()
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;/* w w w .ja v a2 s.c o m*/ 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.agateau.ui.menu.Menu.java
License:Apache License
void onGroupBoundariesChanged() { Actor actor = mGroup.getActor(); actor.setPosition(mStyle.focusPadding, mStyle.focusPadding); setSize(getWidth(), actor.getHeight() + 2 * mStyle.focusPadding); invalidateHierarchy();// w ww .j av a 2 s . com }
From source file:com.agateau.ui.menu.MenuItemGroup.java
License:Apache License
public MenuItem addItemWithLabel(String labelText, MenuItem item) { Actor actor = item.getActor(); float height = actor.getHeight(); float labelWidth = mMenu.getLabelColumnWidth(); Label label = new Label(labelText, mMenu.getSkin()); label.setSize(labelWidth, height);//from ww w . j a va2 s .co m addItemInternal(item, label); return item; }
From source file:com.agateau.ui.menu.MenuItemGroup.java
License:Apache License
private void layoutItems() { // Keep in sync with computeHeight()! float y = 0;// w w w . j a v a2 s.co m Menu.MenuStyle style = mMenu.getMenuStyle(); final float spacing = style.focusPadding * 2 + style.spacing; for (int idx = mItems.size - 1; idx >= 0; --idx) { MenuItem item = mItems.get(idx); ItemInfo info = mInfoForItem.get(item); if (!info.visible) { continue; } Actor actor = item.getActor(); if (actor instanceof Layout) { ((Layout) actor).invalidate(); ((Layout) actor).validate(); } float x = 0; float width = mGroup.getWidth(); if (info.label != null) { info.label.setPosition(0, y); x = mMenu.getLabelColumnWidth(); width -= x; } float ratio = mItemForActor.get(actor).getParentWidthRatio(); if (ratio > 0) { actor.setWidth(width * ratio); } if (info.label == null) { x += (width - actor.getWidth()) / 2; } actor.setPosition(x, y); y += actor.getHeight() + spacing; } }
From source file:com.agateau.ui.menu.MenuItemGroup.java
License:Apache License
private float computeHeight() { // Keep in sync with layoutItems()! float y = 0;/*w w w. j a v a 2 s . co m*/ Menu.MenuStyle style = mMenu.getMenuStyle(); final float spacing = style.focusPadding * 2 + style.spacing; for (int idx = mItems.size - 1; idx >= 0; --idx) { MenuItem item = mItems.get(idx); ItemInfo info = mInfoForItem.get(item); if (!info.visible) { continue; } Actor actor = item.getActor(); y += actor.getHeight() + spacing; } return y - spacing; }
From source file:com.agateau.ui.menu.MenuItemGroup.java
License:Apache License
private MenuItem getItemAt(float x, float y) { for (MenuItem item : mItems) { if (!isItemVisible(item)) { continue; }//from ww w. j a v a2 s. com Actor actor = item.getActor(); // We do not use the item focus rect because it might only represent a part of the item // For example the focus rect of a GridMenuItem is the currently selected cell of the grid mActorRectangle.set(0, 0, actor.getWidth(), actor.getHeight()); for (; actor != mGroup && actor != null; actor = actor.getParent()) { mActorRectangle.x += actor.getX(); mActorRectangle.y += actor.getY(); } if (mActorRectangle.contains(x, y)) { return item; } } return null; }
From source file:com.bagon.matchteam.mtx.scene2d.collision.CollisionDetector.java
License:Apache License
/** * Very precise point detection in an actor, think as virtual box in the * actual box with margin as precision amount * */// w ww . ja v a 2 s. c om public static boolean isTouchPointCollide(float touchX, float touchY, Actor actor, float precisionAmount) { if (touchX > (actor.getX() + precisionAmount) && touchX < (actor.getX() + actor.getWidth() - precisionAmount) && touchY > (actor.getY() + precisionAmount) && touchY < (actor.getY() + actor.getHeight() - precisionAmount)) { logCollision2(actor); return true; } else { return false; } }
From source file:com.bagon.matchteam.mtx.utils.UtilsActor.java
License:Apache License
/** * Get the rectangle of an actor from its current position and size * *//*from w ww .java 2 s. c o m*/ public static Rectangle getRectangleOfActor(Actor actor) { return new Rectangle(actor.getX(), actor.getY(), actor.getWidth(), actor.getHeight()); }
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 w ww. j a va 2s.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.bagon.matchteam.mtx.utils.UtilsPositioner.java
License:Apache License
/** * Set position of an actor due to another actor's position, , since actors * are complex objects, its variables pointing same reference with copies, * so the position will be set in original object * // www . j a v a 2s .com * * @param actorToBePositioned * actor to be positioned * @param actorStable * actor to get position data * @param position * the position to set, comes from Position enum class * */ public static void setActorPoisiton(Actor actorToBePositioned, Actor actorStable, Position position) { float atp_W = actorToBePositioned.getWidth(); float atp_H = actorToBePositioned.getHeight(); float as_X = actorStable.getX(); float as_Y = actorStable.getY(); float as_XW = actorStable.getWidth() + as_X; float as_YH = actorStable.getHeight() + as_Y; setPosition(actorToBePositioned, atp_W, atp_H, as_X, as_Y, as_XW, as_YH, position); }