當前位置: 首頁>>代碼示例>>Java>>正文


Java TiledMapTileLayer類代碼示例

本文整理匯總了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer的典型用法代碼示例。如果您正苦於以下問題:Java TiledMapTileLayer類的具體用法?Java TiledMapTileLayer怎麽用?Java TiledMapTileLayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TiledMapTileLayer類屬於com.badlogic.gdx.maps.tiled包,在下文中一共展示了TiledMapTileLayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: powerMapCoords

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public void powerMapCoords(int x, int y, boolean enable) {
    if (cableMask.atGrid(x, y, false)) {
        TiledMapTileLayer cableLayer = (TiledMapTileLayer) mapSystem.map.getLayers().get("cables");
        final TiledMapTileLayer.Cell cell = cableLayer.getCell(x, y);
        if (cell != null) {
            MapProperties properties = cell.getTile().getProperties();
            if (properties.containsKey("cable-state")) {
                if ((Boolean) properties.get("cable-state") != enable) {
                    cell.setTile(enable ?
                            tilesOn.get((Integer) properties.get("cable-type")) :
                            tilesOff.get((Integer) properties.get("cable-type")));
                    powerMapCoordsAround(x, y, enable);
                }
            }
        }
    }
}
 
開發者ID:DaanVanYperen,項目名稱:odb-artax,代碼行數:18,代碼來源:PowerSystem.java

示例2: PathFindingSystem

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public PathFindingSystem(int mapHeight, int mapWidth, TiledMap tiledMap) {
    super(Family.all(PathComponent.class, TransformComponent.class).get());

    this.mapHeight = mapHeight;
    this.mapWidth = mapWidth;

    map = new TileType[mapWidth][mapHeight];

    TiledMapTileLayer path = (TiledMapTileLayer) tiledMap.getLayers().get("Path");
    TiledMapTileLayer rocks = (TiledMapTileLayer) tiledMap.getLayers().get("Rocks");
    TiledMapTileLayer bushes = (TiledMapTileLayer) tiledMap.getLayers().get("Bushes");

    for (int x = 0; x < map.length; x++) {
        for (int y = 0; y < map[x].length; y++) {
            if (path.getCell(x, y) != null) {
                map[x][y] = TileType.FLOOR;
            } else if (rocks.getCell(x, y) != null || bushes.getCell(x, y) != null) {
                map[x][y] = TileType.WALL;
            } else {
                map[x][y] = TileType.EMPTY;
            }
        }
    }
}
 
開發者ID:MiniDigger,項目名稱:projecttd,代碼行數:25,代碼來源:PathFindingSystem.java

示例3: renderAll

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
/**
 * Rendert alle Layer und alle Objekte
 *
 * @param deltaTime die Zeit, die seit dem letztem Frame vergangen ist
 */
public void renderAll(float deltaTime) {
    beginRender();
    for (MapLayer layer : map.getLayers()) {
        if (layer.isVisible()) {
            if (layer instanceof TiledMapTileLayer) {

                if (layer == displayLayer)
                    renderDisplayLayer((TiledMapTileLayer) layer, deltaTime);
                else
                    renderTileLayer((TiledMapTileLayer)layer);
            } else if (layer instanceof TiledMapImageLayer) {
                renderImageLayer((TiledMapImageLayer)layer);
            } else {
                renderObjects(layer);
            }
        }
    }
    endRender();
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:25,代碼來源:ExtendedOrthogonalTiledMapRenderer.java

示例4: update

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
@Override
public void update(final long elapsedTime) {
    timeInAnimation = (timeInAnimation + elapsedTime) % getTotalAnimationTimeMs();
    final int frameIndex = (int) (timeInAnimation / timePerFrameMs);
    TiledMapTile currentTile = tileFrames.get(indexOrder[frameIndex]);
    for (MapLayer layer : tiledMap.getLayers()) {
        TiledMapTileLayer tiledMapLayer = (TiledMapTileLayer) layer;
        for (int x = 0; x < tiledMapLayer.getWidth(); x++) {
            for (int y = 0; y < tiledMapLayer.getHeight(); y++) {
                final TiledMapTileLayer.Cell cell = tiledMapLayer.getCell(x, y);
                if (cell != null) {
                    TiledMapTile tile = cell.getTile();
                    final MapProperties tileProperties = tile.getProperties();
                    if (tileProperties.containsKey(JRPG_TILE_ANIMATION_ID)
                            && tileProperties.get(JRPG_TILE_ANIMATION_ID).equals(id)) {
                        cell.setTile(currentTile);
                    }
                }
            }
        }
    }
}
 
開發者ID:JayStGelais,項目名稱:jrpg-engine,代碼行數:23,代碼來源:TileAnimation.java

示例5: getDoorTiles

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
private List<MapTile> getDoorTiles(final TiledMapTileLayer layer) {
    final List<MapTile> mapTiles = new LinkedList<>();
    final int layerIndex = layer.getProperties().get(GameMap.MAP_LAYER_PROP_MAP_LAYER, 0, Integer.class);
    for (int x = 0; x < layer.getWidth(); x++) {
        for (int y = 0; y < layer.getHeight(); y++) {
            final TiledMapTileLayer.Cell cell = layer.getCell(x, y);
            TiledMapTile tile = (cell != null) ? cell.getTile() : null;
            if (tile != null && tile.getProperties().get(JRPG_TILE_IS_DOOR, false, Boolean.class)) {
                mapTiles.add(new MapTile(
                        new TileCoordinate(x, y, layerIndex),
                        layer.getName(),
                        tile
                ));
            }
        }
    }

    return mapTiles;
}
 
開發者ID:JayStGelais,項目名稱:jrpg-engine,代碼行數:20,代碼來源:MapScanningDoorGenerator.java

示例6: buildMapLayers

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
private void buildMapLayers(final TiledMap map) {
    for (com.badlogic.gdx.maps.MapLayer mapLayer : map.getLayers()) {
        TiledMapTileLayer tiledMapLayer = (TiledMapTileLayer) mapLayer;

        if (tiledMapLayer.getProperties().containsKey(MAP_LAYER_PROP_MAP_LAYER)) {
            int mapLayerIndex = tiledMapLayer.getProperties().get(MAP_LAYER_PROP_MAP_LAYER, Integer.class);

            MapLayer gameMapLayer = mapLayers.computeIfAbsent(mapLayerIndex, i -> new MapLayer(i, mapRenderer));

            switch (tiledMapLayer.getProperties().get(MAP_LAYER_PROP_LAYER_TYPE, String.class)) {
                case MAP_LAYER_TYPE_BACKGRAOUND:
                    gameMapLayer.addBackgroundLayer(tiledMapLayer);
                    break;
                case MAP_LAYER_TYPE_FOREGRAOUND:
                    gameMapLayer.addForegroundLayer(tiledMapLayer);
                    break;
                case MAP_LAYER_TYPE_COLLISION:
                    gameMapLayer.setCollisionLayer(tiledMapLayer);
                    break;
                default:
            }
        }
    }
}
 
開發者ID:JayStGelais,項目名稱:jrpg-engine,代碼行數:25,代碼來源:GameMap.java

示例7: getCellPropertyFromTopMostTile

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public static <T> T getCellPropertyFromTopMostTile(final TiledMap tiledMap, final TileCoordinate coordinate,
                                                   final String propertyName, final Class<T> clazz) {
    T value = null;
    for (MapLayer mapLayer : tiledMap.getLayers()) {
        if (mapLayer instanceof TiledMapTileLayer
                && matchProperty(mapLayer, GameMap.MAP_LAYER_PROP_MAP_LAYER, coordinate.getMapLayer())) {
            TiledMapTileLayer tiledMapTileLayer = (TiledMapTileLayer) mapLayer;
            TiledMapTileLayer.Cell cell = tiledMapTileLayer.getCell(coordinate.getX(), coordinate.getY());
            if (cell != null) {
                final MapProperties cellProps = cell.getTile().getProperties();
                value = (cellProps.get(propertyName, clazz) != null) ? cellProps.get(propertyName, clazz) : value;
            }
        }
    }

    return value;
}
 
開發者ID:JayStGelais,項目名稱:jrpg-engine,代碼行數:18,代碼來源:TiledUtil.java

示例8: Item

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public Item(MapCellCoordinates cellPos, TextureRegion itemTexture, MapLoader map, EntityManager entityManager) 
{
    super(new ThinGridCoordinates(cellPos.getX(), cellPos.getY()), new ThinGridCoordinates(0,0), map, entityManager);
    
    this.emptyBlock = TextureManager.emptyBlock;
    this.cellPos = cellPos;
    this.sendCommand = entityManager.getSendCommand();
    
    
    
    if(!map.isCellBlocked(cellPos)){
    //Render Item once
    TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
    cell.setTile(new StaticTiledMapTile(itemTexture));
    map.getItemLayer().setCell(cellPos.getX(), cellPos.getY(), cell);
    }else{
        collected = true;
    }
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:20,代碼來源:Item.java

示例9: render

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
@Override
public void render()
{
    if(!map.isCellBlocked(cellPos))
    {
        //Create new cell and set its animation texture
        TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
        cell.setTile(new StaticTiledMapTile(animEffects.getFrame(blockAnim, true)));
        cell.getTile().getProperties().put("poisonGas", null);

        //Set texture into block layer
        blockLayer.setCell(super.cellPos.getX(), super.cellPos.getY(), cell);
    }else
    {
        super.destroyed = true;
    }
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:18,代碼來源:PoisonGas.java

示例10: deleteUp

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public void deleteUp(){
    for(int y=1; y <= explosionRange; y++){
        TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
        cell.setTile(new StaticTiledMapTile(emptyBlock));

        //If explosion hits block
        if(map.isCellBlocked(new MapCellCoordinates(cellPos.getX(), cellPos.getY() + y)))
        {
            //Delete explosion effect
            map.getBombLayer().setCell(cellPos.getX(), cellPos.getY() + y, cell);
            
            //Delete block
            deleteBlock(new MapCellCoordinates(cellPos.getX(), cellPos.getY() + y));
            
            break;
        }
        
        //Explosion down
        map.getBombLayer().setCell(cellPos.getX(), cellPos.getY() + y, cell);
        deleteBlock(new MapCellCoordinates(cellPos.getX(), cellPos.getY() + y));
    }
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:23,代碼來源:Turret.java

示例11: deleteRight

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public void deleteRight(){
    for(int x=1; x <= explosionRange; x++){
        TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
        cell.setTile(new StaticTiledMapTile(emptyBlock));

        //If explosion hits block
        if(map.isCellBlocked(new MapCellCoordinates(cellPos.getX() + x, cellPos.getY())))
        {
            //Delete explosion effect
            map.getBombLayer().setCell(cellPos.getX() + x, cellPos.getY(), cell);
            
            //Delete block
            deleteBlock(new MapCellCoordinates(cellPos.getX() + x, cellPos.getY()));
            
            break;
        }
        
        //Explosion down
        map.getBombLayer().setCell(cellPos.getX() + x, cellPos.getY(), cell);
        deleteBlock(new MapCellCoordinates(cellPos.getX() + x, cellPos.getY()));
    }
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:23,代碼來源:Turret.java

示例12: deleteDown

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public void deleteDown(){
    for(int y=1; y <= explosionRange; y++){
        TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
        cell.setTile(new StaticTiledMapTile(emptyBlock));

        //If explosion hits block
        if(map.isCellBlocked(new MapCellCoordinates(cellPos.getX(), cellPos.getY() - y)))
        {
            //Delete explosion effect
            map.getBombLayer().setCell(cellPos.getX(), cellPos.getY() - y, cell);
            
            //Delete block
            deleteBlock(new MapCellCoordinates(cellPos.getX(), cellPos.getY() - y));
            
            break;
        }
        
        //Explosion down
        map.getBombLayer().setCell(cellPos.getX(), cellPos.getY() - y, cell);
        deleteBlock(new MapCellCoordinates(cellPos.getX(), cellPos.getY() - y));
    }
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:23,代碼來源:Turret.java

示例13: deleteLeft

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public void deleteLeft(){
    for(int x=1; x <= explosionRange; x++){
        TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
        cell.setTile(new StaticTiledMapTile(emptyBlock));

        //If explosion hits block
        if(map.isCellBlocked(new MapCellCoordinates(cellPos.getX() - x, cellPos.getY())))
        {
            //Delete explosion effect
            map.getBombLayer().setCell(cellPos.getX() - x, cellPos.getY(), cell);
            
            //Delete block
            deleteBlock(new MapCellCoordinates(cellPos.getX() - x, cellPos.getY()));
            
            break;
        }
        
        //Explosion down
        map.getBombLayer().setCell(cellPos.getX() - x, cellPos.getY(), cell);
        deleteBlock(new MapCellCoordinates(cellPos.getX() - x, cellPos.getY()));
    }
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:23,代碼來源:Turret.java

示例14: MapLoader

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
public MapLoader(OrthographicCamera camera, SendCommand sendCommand)
{
    this.camera = camera;
    this.tiledMap = new TmxMapLoader().load(Constants.TESTMAPPATH);
    this.tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
    this.blockLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Blocks");
    this.floorLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Floor");
    this.bombLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Bombs");
    this.itemLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Items");
    this.sendCommand = sendCommand;
    
    Constants.MAPTEXTUREWIDTH = blockLayer.getTileWidth();
    Constants.MAPTEXTUREHEIGHT = blockLayer.getTileWidth();
    
    findAllItemFields();
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:17,代碼來源:MapLoader.java

示例15: setNewMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入依賴的package包/類
/**-------------------Getter & Setter-------------------**/
public void setNewMap(String path)
{
    this.tiledMap = new TmxMapLoader().load(path);
    this.tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
    
    this.blockLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Blocks");
    this.floorLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Floor");
    this.bombLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Bombs");
    this.itemLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Items");

    Constants.MAPTEXTUREWIDTH = blockLayer.getTileWidth();
    Constants.MAPTEXTUREHEIGHT = blockLayer.getTileWidth();
    
    findAllItemFields();
}
 
開發者ID:Aeo-Informatik,項目名稱:Space-Bombs,代碼行數:17,代碼來源:MapLoader.java


注:本文中的com.badlogic.gdx.maps.tiled.TiledMapTileLayer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。