本文整理汇总了Java中com.badlogic.gdx.math.Polygon.getBoundingRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.getBoundingRectangle方法的具体用法?Java Polygon.getBoundingRectangle怎么用?Java Polygon.getBoundingRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.Polygon
的用法示例。
在下文中一共展示了Polygon.getBoundingRectangle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPolygon
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
public void setPolygon(Polygon polygon, GameMap map) {
TextureRegion mapSolidTile = Assets.getTextureRegion(Configuration.getFileOrthogonalMapSolidWhiteTileTexture());
// create a new region of size 1x1 in the middle of the solid tile texture
TextureRegion pixel = new TextureRegion(mapSolidTile);
float[] vertices = MathUtil.transformVerticesFromTileToScreen(
polygon.getTransformedVertices(), map);
polyReg = createdPolygonRegion(pixel, vertices);
Rectangle rec = polygon.getBoundingRectangle();
int width = (int) rec.getWidth();
int height = (int) rec.getHeight();
int x = (int) rec.getX();
int y = (int) rec.getY();
boundingRectangleTiles = new int[width * height * 2];
int index = 0;
for (int i = x; i < x + width; ++i) {
for (int j = y; j < y + height; ++j) {
boundingRectangleTiles[index++] = i;
boundingRectangleTiles[index++] = j;
}
}
}
示例2: getTilesFromPolygon
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
private IntArray getTilesFromPolygon(Polygon polygon) {
IntArray tiles = new IntArray();
Polygon transformedPolygon = transformTiledPolygon(gameMap, polygon);
Rectangle rectangle = transformedPolygon.getBoundingRectangle();
int startX = (int) rectangle.getX();
int startY = (int) rectangle.getY();
int endX = startX + (int) rectangle.getWidth();
int endY = startY + (int) rectangle.getHeight();
for (int x = startX; x <= endX; ++x) {
for (int y = startY; y <= endY; ++y) {
if (transformedPolygon.contains(x, y)) {
tiles.add(x);
tiles.add(y);
}
}
}
return tiles;
}
示例3: boundingBoxOf
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
/**
* Returns the bounding box of the given polygon
* @param ptsCombined The points as Vector2 list
* @return A Rectangle object
*/
private Rectangle boundingBoxOf(List<Vector2> ptsCombined) {
float[] rawPtsCombined = new float[ptsCombined.size() * 2];
int ptsCombinedIndex = 0;
for(int i = 0; i < rawPtsCombined.length - 1; i += 2) {
rawPtsCombined[i] = ptsCombined.get(ptsCombinedIndex).x;
rawPtsCombined[i + 1] = ptsCombined.get(ptsCombinedIndex).y;
ptsCombinedIndex++;
}
Polygon polygon = new Polygon();
polygon.setVertices(rawPtsCombined);
Rectangle boundingRect = polygon.getBoundingRectangle();
return boundingRect;
}