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


Java TiledMapTileLayer.setCell方法代碼示例

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


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

示例1: genVoidMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public static TiledMap genVoidMap(int w, int h) {
    ImpassableCells.clear();
    tileAtlas = ResKeeper.get(AtlasId.MAP_TILES);
    TiledMap map = new TiledMap();
    MapLayers layers = map.getLayers();
    TiledMapTileLayer layerBg = new TiledMapTileLayer(w, h, CELL_SIZE,
            CELL_SIZE);
    MapCell cell = getCell(TileCode.GRASS, true);
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            layerBg.setCell(i, j, cell);
        }
    }
    layers.add(layerBg);
    cells.clear();

    return map;
}
 
開發者ID:NaikSoftware,項目名稱:SaveUA,代碼行數:19,代碼來源:MapUtils.java

示例2: setup

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
     * Spawn map entities.
     */
    protected void setup() {
        for (TiledMapTileLayer layer : layers) {

//            private HashMap<String, TiledMapTileLayer> layerIndex = new HashMap<String, TiledMapTileLayer>();
//            layerIndex.put(layer.getName(), layer);

            for (int ty = 0; ty < height; ty++) {
                for (int tx = 0; tx < width; tx++) {
                    final TiledMapTileLayer.Cell cell = layer.getCell(tx, ty);
                    if (cell != null) {
                        final MapProperties properties = cell.getTile().getProperties();

                        if ( properties.containsKey("entity")) {
                            entitySpawnerSystem.spawnEntity(tx * G.CELL_SIZE, ty * G.CELL_SIZE, properties);
                            layer.setCell(tx, ty, null);
                        }
                    }
                }
            }
        }
    }
 
開發者ID:DaanVanYperen,項目名稱:naturally-selected-2d,代碼行數:25,代碼來源:MapSystem.java

示例3: setup

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
 * Spawn map entities.
 */
protected void setup() {
    for (TiledMapTileLayer layer : layers) {
        for (int ty = 0; ty < height; ty++) {
            for (int tx = 0; tx < width; tx++) {
                final TiledMapTileLayer.Cell cell = layer.getCell(tx, ty);
                if (cell != null) {
                    final MapProperties properties = cell.getTile().getProperties();
                    if (properties.containsKey("entity")) {
                        entityFactorySystem.createEntity((String)properties.get("entity"), tx * tileWidth, ty * tileHeight, properties);
                        layer.setCell(tx, ty, null);
                    }
                }
            }
        }
    }
}
 
開發者ID:DaanVanYperen,項目名稱:artemis-odb-contrib,代碼行數:20,代碼來源:TiledMapSystem.java

示例4: create

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
@Override
public void create () {
	super.create();
	float w = Gdx.graphics.getWidth();
	float h = Gdx.graphics.getHeight();

	camera = new OrthographicCamera();
	camera.setToOrtho(false, (w / h) * 480, 480);
	camera.update();

	cameraController = new OrthoCamController(camera);
	Gdx.input.setInputProcessor(cameraController);

	hexture = new Texture(Gdx.files.internal("data/maps/tiled/hex/hexes.png"));
	TextureRegion[][] hexes = TextureRegion.split(hexture, 112, 97);
	map = new TiledMap();
	MapLayers layers = map.getLayers();
	TiledMapTile[] tiles = new TiledMapTile[3];
	tiles[0] = new StaticTiledMapTile(new TextureRegion(hexes[0][0]));
	tiles[1] = new StaticTiledMapTile(new TextureRegion(hexes[0][1]));
	tiles[2] = new StaticTiledMapTile(new TextureRegion(hexes[1][0]));

	for (int l = 0; l < 1; l++) {
		TiledMapTileLayer layer = new TiledMapTileLayer(45, 30, 112, 97);
		for (int y = 0; y < 30; y++) {
			for (int x = 0; x < 45; x++) {
				int id = (int)(Math.random() * 3);
				Cell cell = new Cell();
				cell.setTile(tiles[id]);
				layer.setCell(x, y, cell);
			}
		}
		layers.add(layer);
	}

	renderer = new HexagonalTiledMapRenderer(map);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:38,代碼來源:HexagonalTiledMapTest.java

示例5: create

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
@Override
public void create () {
	float w = Gdx.graphics.getWidth();
	float h = Gdx.graphics.getHeight();

	camera = new OrthographicCamera();
	camera.setToOrtho(false, (w / h) * 320, 320);
	camera.update();

	cameraController = new OrthoCamController(camera);
	Gdx.input.setInputProcessor(cameraController);

	font = new BitmapFont();
	batch = new SpriteBatch();

	{
		tiles = new Texture(Gdx.files.internal("data/maps/tiled/tiles.png"));
		TextureRegion[][] splitTiles = TextureRegion.split(tiles, 32, 32);
		map = new TiledMap();
		MapLayers layers = map.getLayers();
		for (int l = 0; l < 20; l++) {
			TiledMapTileLayer layer = new TiledMapTileLayer(150, 100, 32, 32);
			for (int x = 0; x < 150; x++) {
				for (int y = 0; y < 100; y++) {
					int ty = (int)(Math.random() * splitTiles.length);
					int tx = (int)(Math.random() * splitTiles[ty].length);
					Cell cell = new Cell();
					cell.setTile(new StaticTiledMapTile(splitTiles[ty][tx]));
					layer.setCell(x, y, cell);
				}
			}
			layers.add(layer);
		}
	}

	renderer = new OrthogonalTiledMapRenderer(map);

}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:39,代碼來源:TiledMapBench.java

示例6: generateBricks

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
 * Turn all bricks into actors.
 * @param layer
 */
private void generateBricks(TiledMapTileLayer layer) {
	for (int x = 1; x < layer.getWidth(); x++) {
		for (int y = 1; y < layer.getHeight(); y++) {
			Cell cell = layer.getCell(x, y);
			if(cell != null) {
				TiledMapTile oldTile = cell.getTile();
				if(oldTile.getProperties().containsKey("actor")) {
					String type = (String) oldTile.getProperties().get("actor");
					StaticActor actor = null;
					if(type.equals("Brick") || type.equals("Bonus")) {
						//TODO add other colored bricks
						String color = (String) oldTile.getProperties().get("color");
						boolean destructable = false;
						if(oldTile.getProperties().containsKey("destructable")) {
							
							String destr = (String) oldTile.getProperties().get("destructable");
							destructable = destr.equals("true") ? true : false;
						}
						
						actor = new Brick(this, x, y, color, type.equals("Bonus"), destructable);
						itemsInBrick((Brick) actor, x, y);
					}
					layer.setCell(x, y, null);
					stage.addActor(actor);
				}
			}
		}
	}
}
 
開發者ID:arjanfrans,項目名稱:mario-game,代碼行數:34,代碼來源:World.java

示例7: checkCollidingWithLayer

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
private boolean checkCollidingWithLayer(TiledMapTileLayer layer, float xPosition, float yPosition, boolean remove) {
	int xCell = (int) (xPosition / TILE_SIZE);
	int yCell = (int) (yPosition / TILE_SIZE);
	Cell cell = layer.getCell(xCell, yCell);
	if (remove){
		layer.setCell(xCell, yCell, null);
	}
	return cell != null && cell.getTile() != null;
}
 
開發者ID:dbaelz,項目名稱:Secludedness,代碼行數:10,代碼來源:Level.java

示例8: setTile

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
 * Sets a cell of a tile layer to the given cell.
 * 
 * @param layerName
 *            The name of the layer to edit.
 * @param x
 *            The x coordinate of the tile to edit.
 * @param y
 *            The y coordinate of the tile to edit.
 * @param value
 *            The cell to set the tile to.
 */
public void setTile(String layerName, int x, int y, Cell value) {
	TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(
			layerName); // get the desired layer

	if (layer == null)
		return; // null check

	layer.setCell(x, y, value); // set the desired cell
}
 
開發者ID:LostCodeStudios,項目名稱:JavaLib,代碼行數:22,代碼來源:TileMap.java


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