Created
July 17, 2015 15:06
-
-
Save piotr-j/9279e09f5cf42c003a43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TiledMapTileLayer base = (TiledMapTileLayer)map.getLayers().get(0); | |
int[][] collision = new int[base.getWidth()][base.getHeight()]; | |
for (int x = base.getWidth() - 1; x >= 0; x--) { | |
for (int y = base.getHeight() - 1; y >= 0; y--) { | |
TiledMapTileLayer.Cell cell = base.getCell(x, y); | |
if (cell == null) { | |
Gdx.app.error(TAG, "Null cell at: " + x + " " + y); | |
continue; | |
} | |
TiledMapTile tile = cell.getTile(); | |
if (tile == null) { | |
Gdx.app.error(TAG, "Null tile at: " + x + " " + y); | |
continue; | |
} | |
int id = cell.getId(); | |
// TODO handle more ids | |
if (id == 1) { | |
collision[x][y] = 1; | |
} else { | |
collision[x][y] = 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment