本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell.setTile方法的典型用法代码示例。如果您正苦于以下问题:Java Cell.setTile方法的具体用法?Java Cell.setTile怎么用?Java Cell.setTile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell
的用法示例。
在下文中一共展示了Cell.setTile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateHoles
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void generateHoles() {
Random r = new Random();
int counter = 0;
for (int x = 0; x < pathLayer.getWidth(); ++x)
for (int y = 0; y < pathLayer.getHeight(); ++y) {
Cell cell = pathLayer.getCell(x, y);
if (cell == null)
continue;
else if (cell.getTile().getProperties().containsKey("path")) {
int num = r.nextInt(10 - 1 + 1) + 1;
if (num >= 9) {
++counter;
if (counter <= 4)
cell.setTile(holeTile);
}
else
counter = 0;
}
}
}
示例2: animateTiles
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
/**
* Make the tiles containing 'animation' key animated.
* @param layer
*/
private void animateTiles(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("animation")) {
String animation = (String) oldTile.getProperties().get("animation");
float speed = 0.15f;
if(oldTile.getProperties().containsKey("speed")) {
speed = Float.parseFloat((String) oldTile.getProperties().get("speed"));
}
AnimatedTiledMapTile newTile = new AnimatedTiledMapTile(speed,
Tiles.getAnimatedTile(animation));
newTile.getProperties().putAll(oldTile.getProperties());
cell.setTile(newTile);
}
}
}
}
}
示例3: deleteBlock
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
/**
* Deltes block on given cell position. Spawns also a coin randomly on destroyed blocks.
* If it is undestructable nothing happens and false gets returned.
* @param x: Cell position on x axis
* @param y: Cell position on y axis
* @return boolean
*/
protected boolean deleteBlock(MapCellCoordinates localCellPos)
{
Cell currentCell = blockLayer.getCell(localCellPos.getX() , localCellPos.getY());
if(currentCell != null)
{
//If block is undestructable
if(currentCell.getTile().getProperties().containsKey("undestructable"))
{
return false;
}else
{
//Delete block with empty texture
Cell cell = new Cell();
cell.setTile(new StaticTiledMapTile(emptyBlock));
map.getBlockLayer().setCell(localCellPos.getX(), localCellPos.getY(), cell);
/**---------------------RANDOM COIN---------------------**/
//Check for a bug and if main player placed that bomb
if(currentCell.getTile().getId() != cell.getTile().getId() && playerId == Constants.PLAYERID)
{
dropFromBlock(localCellPos);
}
}
}
// If there is no block
return true;
}
示例4: loadTileLayer
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
protected void loadTileLayer (TiledMap map, Element element) {
if (element.getName().equals("layer")) {
String name = element.getAttribute("name", null);
int width = element.getIntAttribute("width", 0);
int height = element.getIntAttribute("height", 0);
int tileWidth = element.getParent().getIntAttribute("tilewidth", 0);
int tileHeight = element.getParent().getIntAttribute("tileheight", 0);
boolean visible = element.getIntAttribute("visible", 1) == 1;
float opacity = element.getFloatAttribute("opacity", 1.0f);
TiledMapTileLayer layer = new TiledMapTileLayer(width, height, tileWidth, tileHeight);
layer.setVisible(visible);
layer.setOpacity(opacity);
layer.setName(name);
int[] ids = getTileIds(element, width, height);
TiledMapTileSets tilesets = map.getTileSets();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int id = ids[y * width + x];
boolean flipHorizontally = ((id & FLAG_FLIP_HORIZONTALLY) != 0);
boolean flipVertically = ((id & FLAG_FLIP_VERTICALLY) != 0);
boolean flipDiagonally = ((id & FLAG_FLIP_DIAGONALLY) != 0);
TiledMapTile tile = tilesets.getTile(id & ~MASK_CLEAR);
if (tile != null) {
Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
cell.setTile(tile);
layer.setCell(x, height - 1 - y, cell);
}
}
}
Element properties = element.getChildByName("properties");
if (properties != null) {
loadProperties(layer.getProperties(), properties);
}
map.getLayers().add(layer);
}
}
示例5: create
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的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);
}
示例6: create
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的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);
}
示例7: placePlayers
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void placePlayers() {
Cell cell = new Cell();
cell = tokenLayer.getCell((int) arraySquares.get(playerPosition).x, (int) arraySquares.get(playerPosition).y);
cell.setTile(playerTile);
if (!missingWords.isSinglePlayer()) { // Si no es modo SINGLEPLAYER, no colocamos al npc
cell = tokenLayer.getCell((int) arraySquares.get(npcPosition).x, (int) arraySquares.get(npcPosition).y);
cell.setTile(npcTile);
}
}
示例8: changeCellValue
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
public void changeCellValue(int x, int y, int value) {
Cell cell = tileLayer.getCell(x, y);
cell.setTile(map.getTileSets().getTile(value));
}
示例9: openFinalDoor
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void openFinalDoor(Cell cell) {
if(cell !=null && cell.getTile().getProperties().containsKey("finaldoor")){
cell.setTile(new StaticTiledMapTile(new TextureRegion(new TextureRegion(TextureManager.SPECIALDOOROPEN))));
System.out.println("final door opened");
}
}
示例10: openDoor
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void openDoor(Cell cell){
if(cell !=null && cell.getTile().getProperties().containsKey("door")){
cell.setTile(new StaticTiledMapTile(new TextureRegion(new TextureRegion(TextureManager.DOOROPEN))));
System.out.println("door opened");
}
}
示例11: getTilesPosition
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
/**
* Obtiene una lista de celdas con las que colisiona el personaje
* @param startX
* @param startY
* @param endX
* @param endY
* @return
*/
private void getTilesPosition(int startX, int startY, int endX, int endY, Array<Rectangle> tiles) {
tiles.clear();
float tileWidth = TiledMapManager.collisionLayer.getTileWidth();
float tileHeight = TiledMapManager.collisionLayer.getTileHeight();
for (int y = startY; y <= endY; y++) {
for (int x = startX; x <= endX; x++) {
int xCell = (int) (x / tileWidth);
int yCell = (int) (y / tileHeight);
Cell cell = TiledMapManager.collisionLayer.getCell(xCell, yCell);
// Si es un bloque se añade para comprobar colisiones
if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.BLOCKED))) {
Rectangle rect = rectPool.obtain();
// El jugador está saltando (se choca con la cabeza en una celda)
if (velocity.y > 0)
rect.set(x, y, 1, 1);
// El jugador está cayendo (se posa en la celda que tenga debajo)
else
rect.set((int) (Math.ceil(x / tileWidth) * tileWidth), (int) (Math.ceil(y / tileHeight) * tileHeight), 0, 0);
tiles.add(rect);
if (velocity.y > 0)
if (cell.getTile().getProperties().containsKey(TiledMapManager.BOX)) {
// Sale el item de la caja
ResourceManager.getSound("item").play();
LevelManager.raiseItem((int) (Math.ceil(x / tileWidth) * tileWidth),
(int) (Math.ceil(y / tileHeight) * tileHeight));
cell.setTile(TiledMapManager.getEmptyBox(LevelManager.map));
}
}
// Si es una moneda, desaparece
else if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.COIN))) {
LevelManager.removeCoin(xCell, yCell);
}
// Si es un enemigo pierde una vida
else if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.ENEMY))) {
if (!dead) {
die();
}
}
// Si es un cofre se abre y se termina la pantalla
else if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.CHEST))) {
// TODO Terminar la pantalla y pasar a la siguiente
if (!levelCleared) {
levelCleared = true;
LevelManager.finishLevel();
gameController.game.setScreen(new GameScreen(gameController.game));
}
}
}
}
}
示例12: respawnPlayer
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
public void respawnPlayer(int oldPosition, boolean player) {
Cell cell = new Cell();
/* Reproducimos el efecto de sonido si est� activo */
missingWords.getSoundFX().getHole().play(missingWords.getSoundFX().getVolume());
if (player) { // Si es el jugador
cell = tokenLayer.getCell((int) arraySquares.get(oldPosition).x, (int) arraySquares.get(oldPosition).y);
cell.setTile(transparentTile);
playerPosition = 0;
cell = tokenLayer.getCell((int) arraySquares.get(playerPosition).x, (int) arraySquares.get(playerPosition).y);
cell.setTile(playerTile);
}
else { // Si es el NPC
cell = tokenLayer.getCell((int) arraySquares.get(oldPosition).x, (int) arraySquares.get(oldPosition).y);
cell.setTile(transparentTile);
npcPosition = 31;
cell = tokenLayer.getCell((int) arraySquares.get(npcPosition).x, (int) arraySquares.get(npcPosition).y);
cell.setTile(npcTile);
}
}