Example usage for com.badlogic.gdx.maps MapLayers getCount

List of usage examples for com.badlogic.gdx.maps MapLayers getCount

Introduction

In this page you can find the example usage for com.badlogic.gdx.maps MapLayers getCount.

Prototype

public int getCount() 

Source Link

Usage

From source file:br.com.animvs.koalory.entities.engine.graphics.tiles.TileRenderer.java

License:Apache License

@Override
public void render() {
    if (!cached) {
        cached = true;//from ww  w  . j a v a  2s  .  co  m
        count = 0;
        spriteCache.clear();

        final float extraWidth = viewBounds.width * overCache;
        final float extraHeight = viewBounds.height * overCache;
        cacheBounds.x = viewBounds.x - extraWidth;
        cacheBounds.y = viewBounds.y - extraHeight;
        cacheBounds.width = viewBounds.width + extraWidth * 2;
        cacheBounds.height = viewBounds.height + extraHeight * 2;

        for (MapLayer layer : map.getLayers()) {
            spriteCache.beginCache();
            if (layer instanceof TiledMapTileLayer) {
                renderTileLayer((TiledMapTileLayer) layer);
            }
            spriteCache.endCache();
        }
    }

    if (blending) {
        Gdx.gl.glEnable(GL20.GL_BLEND);
        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }

    spriteCache.setShader(controller.getShaderColor().getGDXShader());
    spriteCache.begin();
    controller.getShaderColor().update();

    MapLayers mapLayers = map.getLayers();
    for (int i = 0, j = mapLayers.getCount(); i < j; i++) {
        MapLayer layer = mapLayers.get(i);
        if (layer.isVisible()) {
            spriteCache.draw(i);
            renderObjects(layer);
        }
    }
    spriteCache.end();
    if (blending)
        Gdx.gl.glDisable(GL20.GL_BLEND);
}