Search in sources :

Example 1 with PolygonRegionLoader

use of com.badlogic.gdx.graphics.g2d.PolygonRegionLoader in project libgdx by libgdx.

the class PolygonRegionTest method create.

@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"));
    // create a region from an arbitrary set of vertices (a triangle in this case)
    region2 = new PolygonRegion(new TextureRegion(texture), new float[] { 0, 0, 100, 100, 0, 100 }, new short[] { 0, 1, 2 });
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.x = 0;
    camera.position.y = 0;
    batch = new PolygonSpriteBatch();
    debugRenderer = new PolygonRegionDebugRenderer();
    Gdx.input.setInputProcessor(this);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) PolygonRegionLoader(com.badlogic.gdx.graphics.g2d.PolygonRegionLoader) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Texture(com.badlogic.gdx.graphics.Texture) PolygonSpriteBatch(com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch) PolygonRegion(com.badlogic.gdx.graphics.g2d.PolygonRegion)

Example 2 with PolygonRegionLoader

use of com.badlogic.gdx.graphics.g2d.PolygonRegionLoader in project libgdx by libgdx.

the class PolygonSpriteTest method create.

@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);
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) PolygonRegionLoader(com.badlogic.gdx.graphics.g2d.PolygonRegionLoader) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) PolygonSprite(com.badlogic.gdx.graphics.g2d.PolygonSprite) Texture(com.badlogic.gdx.graphics.Texture) PolygonSpriteBatch(com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Aggregations

OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)2 Texture (com.badlogic.gdx.graphics.Texture)2 PolygonRegionLoader (com.badlogic.gdx.graphics.g2d.PolygonRegionLoader)2 PolygonSpriteBatch (com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 PolygonRegion (com.badlogic.gdx.graphics.g2d.PolygonRegion)1 PolygonSprite (com.badlogic.gdx.graphics.g2d.PolygonSprite)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1