/** Creates a {@link Rectangle} object with the given X and Y coordinates along with a given width and height. * * @param x X coordinate * @param y Y coordinate * @param width Width of the {@link Rectangle} to be created. * @param height Height of the {@link Rectangle} to be created. */ public RectangleMapObject (float x, float y, float width, float height) { super(); rectangle = new Rectangle(x, y, width, height); }
@Override protected Rectangle newObject () { return new Rectangle(); } };
public BatchTiledMapRenderer (TiledMap map, float unitScale, Batch batch) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = batch; this.ownsBatch = false; }
public BatchTiledMapRenderer (TiledMap map, float unitScale, Batch batch) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = batch; this.ownsBatch = false; }
/** Creates a {@link Rectangle} object with the given X and Y coordinates along with a given width and height. * * @param x X coordinate * @param y Y coordinate * @param width Width of the {@link Rectangle} to be created. * @param height Height of the {@link Rectangle} to be created. */ public RectangleMapObject (float x, float y, float width, float height) { super(); rectangle = new Rectangle(x, y, width, height); }
public BatchTiledMapRenderer (TiledMap map, float unitScale) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = new SpriteBatch(); this.ownsBatch = true; }
public BatchTiledMapRenderer (TiledMap map, float unitScale) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = new SpriteBatch(); this.ownsBatch = true; }
/** Returns an axis-aligned bounding box of this polygon. * * Note the returned Rectangle is cached in this polygon, and will be reused if this Polygon is changed. * * @return this polygon's bounding box {@link Rectangle} */ public Rectangle getBoundingRectangle () { float[] vertices = getTransformedVertices(); float minX = vertices[0]; float minY = vertices[1]; float maxX = vertices[0]; float maxY = vertices[1]; final int numFloats = vertices.length; for (int i = 2; i < numFloats; i += 2) { minX = minX > vertices[i] ? vertices[i] : minX; minY = minY > vertices[i + 1] ? vertices[i + 1] : minY; maxX = maxX < vertices[i] ? vertices[i] : maxX; maxY = maxY < vertices[i + 1] ? vertices[i + 1] : maxY; } if (bounds == null) bounds = new Rectangle(); bounds.x = minX; bounds.y = minY; bounds.width = maxX - minX; bounds.height = maxY - minY; return bounds; }
/** Returns an axis-aligned bounding box of this polygon. * * Note the returned Rectangle is cached in this polygon, and will be reused if this Polygon is changed. * * @return this polygon's bounding box {@link Rectangle} */ public Rectangle getBoundingRectangle () { float[] vertices = getTransformedVertices(); float minX = vertices[0]; float minY = vertices[1]; float maxX = vertices[0]; float maxY = vertices[1]; final int numFloats = vertices.length; for (int i = 2; i < numFloats; i += 2) { minX = minX > vertices[i] ? vertices[i] : minX; minY = minY > vertices[i + 1] ? vertices[i + 1] : minY; maxX = maxX < vertices[i] ? vertices[i] : maxX; maxY = maxY < vertices[i + 1] ? vertices[i + 1] : maxY; } if (bounds == null) bounds = new Rectangle(); bounds.x = minX; bounds.y = minY; bounds.width = maxX - minX; bounds.height = maxY - minY; return bounds; }
/** Returns the bounding axis aligned {@link Rectangle} that bounds this sprite. The rectangles x and y coordinates describe its * bottom left corner. If you change the position or size of the sprite, you have to fetch the triangle again for it to be * recomputed. * * @return the bounding Rectangle */ public Rectangle getBoundingRectangle () { final float[] vertices = getVertices(); float minx = vertices[X1]; float miny = vertices[Y1]; float maxx = vertices[X1]; float maxy = vertices[Y1]; minx = minx > vertices[X2] ? vertices[X2] : minx; minx = minx > vertices[X3] ? vertices[X3] : minx; minx = minx > vertices[X4] ? vertices[X4] : minx; maxx = maxx < vertices[X2] ? vertices[X2] : maxx; maxx = maxx < vertices[X3] ? vertices[X3] : maxx; maxx = maxx < vertices[X4] ? vertices[X4] : maxx; miny = miny > vertices[Y2] ? vertices[Y2] : miny; miny = miny > vertices[Y3] ? vertices[Y3] : miny; miny = miny > vertices[Y4] ? vertices[Y4] : miny; maxy = maxy < vertices[Y2] ? vertices[Y2] : maxy; maxy = maxy < vertices[Y3] ? vertices[Y3] : maxy; maxy = maxy < vertices[Y4] ? vertices[Y4] : maxy; if (bounds == null) bounds = new Rectangle(); bounds.x = minx; bounds.y = miny; bounds.width = maxx - minx; bounds.height = maxy - miny; return bounds; }
/** Returns the bounding axis aligned {@link Rectangle} that bounds this sprite. The rectangles x and y coordinates describe its * bottom left corner. If you change the position or size of the sprite, you have to fetch the triangle again for it to be * recomputed. * * @return the bounding Rectangle */ public Rectangle getBoundingRectangle () { final float[] vertices = getVertices(); float minx = vertices[X1]; float miny = vertices[Y1]; float maxx = vertices[X1]; float maxy = vertices[Y1]; minx = minx > vertices[X2] ? vertices[X2] : minx; minx = minx > vertices[X3] ? vertices[X3] : minx; minx = minx > vertices[X4] ? vertices[X4] : minx; maxx = maxx < vertices[X2] ? vertices[X2] : maxx; maxx = maxx < vertices[X3] ? vertices[X3] : maxx; maxx = maxx < vertices[X4] ? vertices[X4] : maxx; miny = miny > vertices[Y2] ? vertices[Y2] : miny; miny = miny > vertices[Y3] ? vertices[Y3] : miny; miny = miny > vertices[Y4] ? vertices[Y4] : miny; maxy = maxy < vertices[Y2] ? vertices[Y2] : maxy; maxy = maxy < vertices[Y3] ? vertices[Y3] : maxy; maxy = maxy < vertices[Y4] ? vertices[Y4] : maxy; if (bounds == null) bounds = new Rectangle(); bounds.x = minx; bounds.y = miny; bounds.width = maxx - minx; bounds.height = maxy - miny; return bounds; }
@Test public void testToString () { assertEquals("[5.0,-4.1,0.03,-0.02]", new Rectangle(5f, -4.1f, 0.03f, -0.02f).toString()); }
/** Creates a {@link Rectangle} object with the given X and Y coordinates along with a given width and height. * * @param x X coordinate * @param y Y coordinate * @param width Width of the {@link Rectangle} to be created. * @param height Height of the {@link Rectangle} to be created. */ public RectangleMapObject (float x, float y, float width, float height) { super(); rectangle = new Rectangle(x, y, width, height); }
public BatchTiledMapRenderer (TiledMap map, float unitScale, Batch batch) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = batch; this.ownsBatch = false; }
/** @return first widgets bounds, changing returned rectangle values does not have any effect */ public Rectangle getFirstWidgetBounds () { return new Rectangle(firstWidgetBounds); }
public BatchTiledMapRenderer (TiledMap map, float unitScale) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = new SpriteBatch(); this.ownsBatch = true; }
public Tube(float x){ topTube = new Texture("toptube.png"); bottomTube = new Texture("bottomtube.png"); rand = new Random(); posTopTube = new Vector2(x, rand.nextInt(FLUCTUATION) + LOWEST_OPENING + TUBE_GAP); posBottomTube = new Vector2(x, posTopTube.y - TUBE_GAP - bottomTube.getHeight()); boundsTop = new Rectangle(posTopTube.x, posTopTube.y, topTube.getWidth(), topTube.getHeight()); boundsBottom = new Rectangle(posBottomTube.x, posBottomTube.y, bottomTube.getWidth(), bottomTube.getHeight()); }