Skip to content

Instantly share code, notes, and snippets.

@piotr-j
Created July 17, 2015 15:06
Show Gist options
  • Save piotr-j/9279e09f5cf42c003a43 to your computer and use it in GitHub Desktop.
Save piotr-j/9279e09f5cf42c003a43 to your computer and use it in GitHub Desktop.
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