Example usage for com.badlogic.gdx.graphics.g2d.tiled TiledLayer getHeight

List of usage examples for com.badlogic.gdx.graphics.g2d.tiled TiledLayer getHeight

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d.tiled TiledLayer getHeight.

Prototype

public int getHeight() 

Source Link

Usage

From source file:com.sertaogames.cactus2d.components.TileMapPhysics.java

License:Open Source License

private void createFromBlocks() {
    TiledLayer physicsLayer = null;
    for (TiledLayer layer : tm.tilemap.layers) {
        if (layer.name.equals(physicsLayerName))
            physicsLayer = layer;// w  w  w  . j  a  v a2s  . c  o m
    }

    for (int i = 0; i < physicsLayer.getHeight(); i++) {
        int begin = -1;
        int last = -1;
        for (int j = 0; j < physicsLayer.getWidth(); j++) {
            int tile = physicsLayer.tiles[i][j];
            // System.out.println(tile);

            if (tile != 0) {
                last = j;
                if (begin < 0) {
                    begin = j;
                }
            }

            if ((j == physicsLayer.getWidth() - 1 || tile == 0) && last >= 0) {
                createBodyFromBlocks(begin, last, i);
                begin = -1;
                last = -1;
            }
        }
    }
}