Java Code Examples for com.badlogic.gdx.maps.tiled.TiledMapTileLayer#getHeight()

The following examples show how to use com.badlogic.gdx.maps.tiled.TiledMapTileLayer#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TiledMapStage.java    From Norii with Apache License 2.0 5 votes vote down vote up
public TiledMapStage(Map tiledMap, String layername, BattleManager battlemanager) {
    this.tiledMap = tiledMap;
    this.battlemanager = battlemanager;
    TiledMapTileLayer tiledLayer = (TiledMapTileLayer) tiledMap.getCurrentTiledMap().getLayers().get(layername);
    actors = new TiledMapActor[tiledLayer.getWidth()][tiledLayer.getHeight()];
    createActorsForLayer(tiledLayer);  
}
 
Example 2
Source File: TiledMapStage.java    From Norii with Apache License 2.0 5 votes vote down vote up
private void createActorsForLayer(TiledMapTileLayer tiledLayer) {
    for (int x = 0; x < tiledLayer.getWidth(); x++) {
        for (int y = 0; y < tiledLayer.getHeight(); y++) {
            TiledMapTileLayer.Cell cell = tiledLayer.getCell(x, y);
            TiledMapActor actor = new TiledMapActor(tiledMap, tiledLayer, cell);
            actors[x][y] = actor;
            
            initiateActor(x, y, actor);
            addEventListener(actor);
        }
    }
}
 
Example 3
Source File: WorldRenderer.java    From killingspree with MIT License 5 votes vote down vote up
public void loadLevel(String level, boolean isServer, String name) {
    this.isServer = isServer;
    map = new TmxMapLoader().load(level);
    TiledMapTileLayer layer = (TiledMapTileLayer) map.
                                getLayers().get("terrain");
    VIEWPORT_WIDTH = (int) (layer.getTileWidth() * layer.getWidth());
    VIEWPORT_HEIGHT = (int) (layer.getTileHeight() * layer.getHeight());
    viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, camera);
    renderer = new OrthogonalTiledMapRenderer(map);
    name = name.trim();
    if (name.length() == 0)
        name = "noname";
    if (name.length() >= 10){
        name = name.substring(0, 10);
    }
    ClientDetailsMessage clientDetails = new ClientDetailsMessage();
    clientDetails.name = name;
    clientDetails.protocolVersion = Constants.PROTOCOL_VERSION;
    if (isServer) {
        MapLayer collision =  map.
                getLayers().get("collision");
        for(MapObject object: collision.getObjects()) {
            worldManager.createWorldObject(object);
        }
        worldManager.addIncomingEvent(MessageObjectPool.instance.
                eventPool.obtain().set(State.RECEIVED, clientDetails));
    } else {
        client.sendTCP(clientDetails);
    }
    controls = new onScreenControls();
    
}