当前位置: 首页>>代码示例>>Java>>正文


Java Polygon.getBoundingRectangle方法代码示例

本文整理汇总了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;
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:23,代码来源:FilledPolygonRenderer.java

示例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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:19,代码来源:GameMapLoader.java

示例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;
}
 
开发者ID:tavuntu,项目名称:tabox2d,代码行数:20,代码来源:Tabox2D.java


注:本文中的com.badlogic.gdx.math.Polygon.getBoundingRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。