本文整理汇总了Java中com.badlogic.gdx.math.Polygon类的典型用法代码示例。如果您正苦于以下问题:Java Polygon类的具体用法?Java Polygon怎么用?Java Polygon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Polygon类属于com.badlogic.gdx.math包,在下文中一共展示了Polygon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makePolygonGround
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
/**
* Creates polygon ground from the given object, at the given world.
*
* @param world The world were the ground will be.
* @param object The object used to initialize the ground.
* @return The body of the created ground.
*/
static Body makePolygonGround(World world, PolygonMapObject object) {
Polygon polygon = object.getPolygon();
// Body and Fixture variables
BodyDef bdef = new BodyDef();
FixtureDef fdef = new FixtureDef();
PolygonShape shape = new PolygonShape();
bdef.type = BodyDef.BodyType.StaticBody;
bdef.position.set(PIXEL_TO_METER * polygon.getX(), PIXEL_TO_METER * polygon.getY());
Body body = world.createBody(bdef);
float[] new_vertices = polygon.getVertices().clone();
for (int i = 0; i < new_vertices.length; i++)
new_vertices[i] *= PIXEL_TO_METER;
shape.set(new_vertices);
fdef.shape = shape;
fdef.filter.categoryBits = GROUND_BIT;
body.createFixture(fdef);
return body;
}
示例2: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
/**
* Retrieves a polygon from the polygon cache, with a specified width and height
*
* @param name the polygon to retrieve
* @param width the width of the polygon
* @param height the height of the polygon
*
* @return the loaded polygon
*/
public static Polygon getPolygon(String name, float width, float height) {
if(! polygons.containsKey(name))
loadPolygon(name);
Polygon temp = polygons.get(name);
float[] tempVertices = temp.getVertices();
float[] returnVertices = new float[tempVertices.length];
for(int i = 0; i < tempVertices.length; i++)
{
if(i % 2 == 0)
returnVertices[i] = tempVertices[i] * width;
else returnVertices[i] = tempVertices[i] * height;
}
Polygon ret = new Polygon(returnVertices);
ret.setOrigin(width/2, height/2);
return ret;
//NOTE: Origin might need to be revisited
}
示例3: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 16, y - 5,
x + 16, y + 1,
x + 8, y + 9,
x, y + 8,
x - 8, y + 9,
x - 16, y + 1,
x - 16, y - 5,
x, y - 9
};
return new Polygon(vertices);
}
示例4: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 6, y - 15,
x + 6, y,
x + 8, y,
x + 8, y + 3,
x + 12, y + 15,
x + 9, y + 15,
x + 5, y + 4,
x - 2, y + 14,
x - 3, y + 14,
x - 3, y + 7,
x - 7, y + 7,
x - 11, y + 3,
x - 8, y - 1,
x - 12, y - 15,
};
return new Polygon(vertices);
}
示例5: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x, y - 3,
x + 3, y - 5,
x + 6, y,
x + 4, y + 5,
x, y + 2,
x - 4, y + 5,
x - 6, y,
x - 3, y - 5,
};
return new Polygon(vertices);
}
示例6: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 6, y - 10,
x + 9, y - 5,
x + 6, y - 2,
x + 10, y + 3,
x + 10, y + 7,
x + 13, y + 7,
x + 13, y + 10,
x + 7, y + 10,
x + 7, y + 4,
x + 3, y + 4,
x + 1, y + 10,
x - 4, y + 8,
x - 9, y + 10,
x - 13, y - 2,
x - 13, y - 10,
x - 7, y - 10,
x - 3, y - 4,
x + 1, y - 10
};
return new Polygon(vertices);
}
示例7: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 36, y - 1,
x + 18, y + 11,
x + 5, y + 8,
x - 5, y + 12,
x - 25, y + 10,
x - 36, y + 2,
x - 32, y - 10,
x - 15, y - 8,
x + 2, y - 12,
x + 18, y - 12,
x + 34, y - 7,
};
return new Polygon(vertices);
}
示例8: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 5, y - 10,
x + 13, y + 2,
x + 13, y + 7,
x + 10, y + 10,
x + 7, y,
x, y + 10,
x - 4, y + 10,
x - 14, y + 5,
x - 14, y - 1,
x - 12, y - 8,
x - 14, y - 8,
x - 14, y - 11,
x - 9, y - 11,
x - 5, y - 5,
x, y - 10
};
return new Polygon(vertices);
}
示例9: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 13, y,
x + 14, y + 3,
x + 10, y + 7,
x + 6, y,
x + 3, y,
x - 5, y + 6,
x + 3, y + 8,
x - 15, y + 6,
x - 7, y + 4,
x - 14, y - 1,
x - 14, y - 8,
x - 9, y - 6,
x - 9, y - 8,
x - 4, y - 8,
x - 2, y - 5,
};
return new Polygon(vertices);
}
示例10: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x, y - 16,
x + 2, y - 8,
x + 16, y + 2,
x + 16, y + 12,
x, y + 12,
x - 1, y + 15,
x - 5, y + 15,
x - 8, y + 10,
x - 11, y + 16,
x - 14, y + 12,
x - 11, y + 1,
x - 16, y,
x - 16, y - 3,
x - 8, y - 8,
x - 7, y - 15
};
return new Polygon(vertices);
}
示例11: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 16, y - 3,
x + 8, y + 3,
x + 13, y + 5,
x + 13, y + 6,
x - 4, y + 6,
x - 16, y + 7,
x - 11, y + 4,
x - 16, y - 1,
x - 6, y - 1,
x - 3, y - 7,
x + 11, y - 7,
};
return new Polygon(vertices);
}
示例12: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 16, y - 5,
x + 16, y + 3,
x + 2, y + 5,
x + 2, y + 12,
x - 4, y + 12,
x - 6, y,
x - 16, y,
x - 16, y - 9,
x - 14, y - 12,
x + 11, y - 12
};
return new Polygon(vertices);
}
示例13: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 16, y - 5,
x + 6, y + 10,
x + 3, y + 8,
x - 3, y + 14,
x - 9, y + 11,
x - 6, y + 7,
x - 15, y + 5,
x - 15, y - 13,
x + 10, y - 13
};
return new Polygon(vertices);
}
示例14: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 5, y - 2,
x + 5, y + 4,
x + 1, y + 15,
x - 5, y + 16,
x - 5, y - 4,
x - 3, y - 4,
x - 3, y - 16,
x + 3, y - 16,
x + 3, y - 4,
x + 5, y - 4,
};
return new Polygon(vertices);
}
示例15: getPolygon
import com.badlogic.gdx.math.Polygon; //导入依赖的package包/类
@Override
public Polygon getPolygon() {
float x = getPosition().x;
float y = getPosition().y;
float[] vertices = {
x + 10, y - 5,
x + 14, y + 3,
x + 8, y + 13,
x - 8, y + 13,
x - 14, y + 3,
x - 10, y - 5,
x - 3, y - 13,
x + 3, y - 13
};
return new Polygon(vertices);
}