Example usage for com.badlogic.gdx.maps.tiled TiledMap dispose

List of usage examples for com.badlogic.gdx.maps.tiled TiledMap dispose

Introduction

In this page you can find the example usage for com.badlogic.gdx.maps.tiled TiledMap dispose.

Prototype

@Override
    public void dispose() 

Source Link

Usage

From source file:com.tumblr.oddlydrawn.stupidworm.Level.java

License:Apache License

public void loadLevel() {
    TiledMap tiledMap;
    TiledMapTileLayer layer;//  w w w.ja  va2 s  .com
    Cell cell;

    // Creates the map objects and loads the appropriate level.
    tiledMap = new TiledMap();
    cell = new Cell();
    tiledMap = new TmxMapLoader().load(level);

    // Gets the collision layer from the map.
    layer = (TiledMapTileLayer) tiledMap.getLayers().get(0);
    cell = layer.getCell(0, 0);
    int width = layer.getWidth();
    int height = layer.getHeight();

    // Goes through all the tiles in the layer, looking for tiles with walls
    // and a single tile with the start position for the worm.
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            cell = layer.getCell(x, y);
            if (cell != null) {
                if (hasCollides(cell)) {
                    levelArray[x][y] = 1;
                } else if (hasStart(cell)) {
                    startCoords.x = x * SIZE;
                    startCoords.y = y * SIZE;
                    levelArray[x][y] = 0;
                } else {
                    levelArray[x][y] = 0;
                }
            }
        }
    }
    tiledMap.dispose();
}