Search in sources :

Example 6 with SpriteCache

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

the class IsometricTileTest method render.

@Override
public void render() {
    Gdx.gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    cam.update();
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    for (int i = 0; i < LAYERS; i++) {
        SpriteCache cache = caches[i];
        cache.setProjectionMatrix(cam.combined);
        cache.begin();
        cache.draw(layers[i]);
        cache.end();
    }
    renderer.setProjectionMatrix(cam.combined);
    renderer.begin(ShapeType.Line);
    renderer.setColor(1, 0, 0, 1);
    renderer.line(0, 0, 500, 0);
    renderer.line(0, 0, 0, 500);
    renderer.setColor(0, 0, 1, 1);
    renderer.line(0, BOUND_Y, BOUND_X, BOUND_Y);
    renderer.setColor(0, 0, 1, 1);
    renderer.line(BOUND_X, 0, BOUND_X, BOUND_Y);
    renderer.end();
}
Also used : SpriteCache(com.badlogic.gdx.graphics.g2d.SpriteCache)

Example 7 with SpriteCache

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

the class TileTest method render.

@Override
public void render() {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    cam.update();
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    for (int i = 0; i < LAYERS; i++) {
        SpriteCache cache = caches[i];
        cache.setProjectionMatrix(cam.combined);
        cache.begin();
        for (int j = 0; j < TILES_PER_LAYER; j += BLOCK_TILES) {
            cache.draw(layers[i], j, BLOCK_TILES);
        }
        cache.end();
    }
    if (TimeUtils.nanoTime() - startTime >= 1000000000) {
        Gdx.app.log("TileTest", "fps: " + Gdx.graphics.getFramesPerSecond());
        startTime = TimeUtils.nanoTime();
    }
}
Also used : SpriteCache(com.badlogic.gdx.graphics.g2d.SpriteCache)

Aggregations

SpriteCache (com.badlogic.gdx.graphics.g2d.SpriteCache)7 Texture (com.badlogic.gdx.graphics.Texture)4 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)2 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)2 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)2 Random (java.util.Random)2 Pixmap (com.badlogic.gdx.graphics.Pixmap)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1