List of usage examples for com.badlogic.gdx.math Vector2 set
public Vector2 set(float x, float y)
From source file:vault.clockwork.editor.gui.GUIElement.java
License:Open Source License
/** * Calculates the element bounds.//from w w w . j a v a2 s . com * @param anchor * @param space * @param position * @param width * @param height * @return */ public static Rectangle calculateBounds(Anchor anchor, ScreenSpace space, Vector2 position, float width, float height) { final Vector2 screen = position.cpy(); // calculate screen spacing position switch (space) { case TopRight: screen.set(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); screen.x -= position.x; screen.y -= position.y; break; case TopLeft: screen.set(0, Gdx.graphics.getHeight()); screen.x += position.x; screen.y -= position.y; break; case BottomRight: screen.set(Gdx.graphics.getWidth(), 0); screen.x -= position.x; screen.y += position.y; break; case Center: screen.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2); screen.x += position.x; screen.y += position.y; break; } // calculate screen bounds over the anchor switch (anchor) { case TopRight: return new Rectangle(screen.x - width, screen.y - height, width, height); case TopLeft: return new Rectangle(screen.x, screen.y - height, width, height); case BottomRight: return new Rectangle(screen.x - width, screen.y, width, height); case Center: return new Rectangle(screen.x - width / 2, screen.y - height / 2, width, height); default: return new Rectangle(screen.x, screen.y, width, height); } }