Java 类com.badlogic.gdx.graphics.g2d.PolygonSprite 实例源码

项目:libgdxcn    文件:PolygonSpriteTest.java   
@Override
public void create () {
    texture = new Texture(Gdx.files.internal("data/tree.png"));

    PolygonRegionLoader loader = new PolygonRegionLoader();
    region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh"));

    renderer = new ShapeRenderer();

    camera = new OrthographicCamera(480, 320);
    camera.position.x = 240;
    camera.position.y = 160;
    camera.update();

    batch = new PolygonSpriteBatch();

    for (int i = 0; i < 50; i++) {
        PolygonSprite sprite = new PolygonSprite(region);
        sprite.setPosition(MathUtils.random(-30, 440), MathUtils.random(-30, 290));
        sprite.setColor(MathUtils.random(), MathUtils.random(), MathUtils.random(), 1.0f);
        sprite.setScale(MathUtils.random(0.5f, 1.5f), MathUtils.random(0.5f, 1.5f));
        sprites.add(sprite);
    }
}
项目:ead    文件:TexturedShapeEditor.java   
@Override
public void create() {
    super.create();

    executor = new AsyncExecutor(1);

    // create a string of generally-overlapping polygons, will draw in
    // blue
    GeoTester.randomPolys(3, 40, 80, new Vector2(100, 300), blue);
    float s = 10;
    Polygon p0 = new Polygon(new float[] {
            // north-west, low, north-east
            0, 3 * s, 0, 2 * s, 2 * s, 0, 3 * s, 0, 4.5f * s, 2 * s, 6 * s,
            0, 7 * s, 0, 9 * s, 2 * s, 9 * s, 3 * s,
            // north-east, high, north-west
            8 * s, 3 * s, 6.5f * s, 1 * s, 5 * s, 3 * s, 4 * s, 3 * s,
            2.5f * s, s, 1 * s, 3 * s });
    blue.add(p0);
    // merge them into a single polygon, will draw in red
    for (Polygon bp : blue) {
        GeometryUtils.merge(geo, bp);
    }
    Geometry collapsed = GeometryUtils.collapse(geo);
    Polygon p = GeometryUtils.jtsCoordsToGdx(collapsed.getCoordinates());
    red.add(p);

    triangles = GeometryUtils.triangulate(collapsed);
    Gdx.app.error("GeoTester", "ready to display triangles worth "
            + triangles.length + " vertices");

    // use the polygon to clip a randomly-generated texture
    textureSolid = new Texture(GeoTester.randomPixmap(100, 100, null),
            false);

    PolygonRegion polyReg = new PolygonRegion(new TextureRegion(
            textureSolid), p.getVertices(), triangles);
    poly = new PolygonSprite(polyReg);
    poly.setOrigin(p.getVertices()[0], p.getVertices()[1]);
    polyBatch = new PolygonSpriteBatch();

    // prepare rendering aids
    shapeRenderer = new ShapeRenderer();

    Gdx.input.setInputProcessor(this);
}
项目:RubeLoader    文件:PolySpatial.java   
public PolySpatial(PolygonRegion region, Color color) {
    mSprite = new PolygonSprite(region);
    mSprite.setColor(color);
    mSprite.setSize(region.getRegion().getRegionWidth()/PIXELS_PER_METER,region.getRegion().getRegionHeight()/PIXELS_PER_METER);
}
项目:RubeLoader    文件:PolySpatial.java   
public PolySpatial(PolygonRegion region, Color color) {
    mSprite = new PolygonSprite(region);
    mSprite.setColor(color);
    mSprite.setSize(region.getRegion().getRegionWidth()/PIXELS_PER_METER,region.getRegion().getRegionHeight()/PIXELS_PER_METER);
}