private int mapHeightPixels;\r
private int tileWidth, tileHeight;\r
private int tilesPerBlockX, tilesPerBlockY;\r
+ private int[] allLayers;\r
\r
private IntArray blendedTiles;\r
\r
\r
int layer, row, col;\r
\r
+ allLayers = new int[map.length];\r
+ \r
// Calculate maximum cache size and map height in pixels\r
+ // Fill allLayers array\r
int maxCacheSize = 0;\r
int maxHeight = 0;\r
for (layer = 0; layer < map.length; layer++) {\r
+ allLayers[layer] = layer;\r
if (map[layer].length > maxHeight) maxHeight = map[layer].length;\r
for (row = 0; row < map[layer].length; row++) {\r
for(col = 0; col < map[layer][row].length; col++)\r
* {@link TileMapRenderer#render(float, float, int, int, int[])} with all layers in the layers list.\r
*/\r
public void render (float x, float y, int width, int height) {\r
- render(x, y, width, height, null);\r
+ render(x, y, width, height, allLayers);\r
}\r
\r
/**\r
* @param width the width of the tiles to draw (in pixels)\r
* @param height the width of the tiles to draw (in pixels)\r
* @param layers The list of layers to draw, 0 being the lowest layer. You will get an IndexOutOfBoundsException if a layer\r
- * number is too high. A null argument draws all layers.\r
+ * number is too high.\r
*/\r
public void render (float x, float y, int width, int height, int[] layers) {\r
initialRow = (int)((mapHeightPixels - y - overdrawY) / (tilesPerBlockY * tileHeight));\r
Gdx.gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);\r
\r
cache.begin();\r
- for (currentLayer = 0; (layers == null) ? (currentLayer < normalCacheId.length) : (currentLayer < layers.length); currentLayer++) {\r
+ for (currentLayer = 0; currentLayer < layers.length; currentLayer++) {\r
for (currentRow = initialRow; currentRow <= lastRow && currentRow < getLayerHeightInBlocks(currentLayer); currentRow++) {\r
for (currentCol = initialCol; currentCol <= lastCol && currentCol < getLayerWidthInBlocks(currentLayer, currentRow); currentCol++) {\r
Gdx.gl.glDisable(GL10.GL_BLEND);\r
- cache.draw(normalCacheId[currentLayer][currentRow][currentCol]);\r
+ cache.draw(normalCacheId[layers[currentLayer]][currentRow][currentCol]);\r
Gdx.gl.glEnable(GL10.GL_BLEND);\r
- cache.draw(blendedCacheId[currentLayer][currentRow][currentCol]);\r
+ cache.draw(blendedCacheId[layers[currentLayer]][currentRow][currentCol]);\r
}\r
}\r
}\r
private static final int SCREEN_WIDTH = 480;\r
private static final int SCREEN_HEIGHT = 320;\r
\r
- // private static final int[] layersList = {0,1,2,3};\r
+ private static final int[] layersList = {2,3};\r
\r
SpriteBatch spriteBatch;\r
BitmapFont font;\r
tmp.set(0, 0, 0);\r
cam.unproject(tmp);\r
\r
- tileMapRenderer.render(tmp.x, tmp.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+ tileMapRenderer.render(tmp.x, tmp.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), layersList);\r
\r
spriteBatch.begin();\r
font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 20, 20);\r