本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell.getTile方法的典型用法代码示例。如果您正苦于以下问题:Java Cell.getTile方法的具体用法?Java Cell.getTile怎么用?Java Cell.getTile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell
的用法示例。
在下文中一共展示了Cell.getTile方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSolidTiles
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void initSolidTiles(TiledMap map){
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get("CollisionTiles");
for(int x = 0; x < layer.getWidth(); x++){
for(int y = 0; y < layer.getHeight(); y++){
Cell cell = layer.getCell(x, y);
if(cell == null){
solids[x][y] = false;
continue;
}
if(cell.getTile() == null){
solids[x][y] = false;
continue;
}
else{
solids[x][y] = true;
}
}
}
}
示例2: initBlocks
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void initBlocks(WorldTypeEnum background) {
blocks = new ArrayList<AbstractBlock>();
wallBlocks = new ArrayList<WallBlock>();
for (int i = 0; i < tileLayer.getWidth(); i++) {
for (int j = 0; j < tileLayer.getHeight(); j++) {
Cell cell = tileLayer.getCell(i, j);
if (cell != null) {
TiledMapTile tile = cell.getTile();
int id = tile.getId();
BlockTypeEnum blockTypeEnum = TileIdConstants.getSpecialBlockType(id);
if (blockTypeEnum==BlockTypeEnum.MYSTERY_BLOCK) {
blocks.add(new MysteryBlock(i, j, id, background));
} else if (blockTypeEnum==BlockTypeEnum.WALL_BLOCK) {
wallBlocks.add(new WallBlock(i, j, id, background));
} else if (blockTypeEnum==BlockTypeEnum.MYSTERY_BLOCK_INVISIBLE) {
blocks.add(new InvisibleMysteryBlock(i, j, id, background));
}
}
}
}
}
示例3: CastleLevelEndingSceneHandler
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
public CastleLevelEndingSceneHandler(Mario mario, TmxMap tileMap, GameCamera camera,
Array<IScrollingBackground> scrollingBbackgrounds, BitmapFont font, SpriteBatch spriteBatch,
OrthogonalTiledMapRenderer renderer, Stage stage, Batch batch) {
super(mario, tileMap, camera, scrollingBbackgrounds, font, spriteBatch, renderer, stage, batch);
for (int i = 0; i < tileMap.getTileLayer().getWidth(); i++) {
for (int j = 0; j < tileMap.getTileLayer().getHeight(); j++) {
Cell cell = tileMap.getTileLayer().getCell(i, j);
if (cell != null) {
TiledMapTile tile = cell.getTile();
int id = tile.getId();
if (id==118) {
tileToRemove.add(new Vector2(i,j));
}
}
}
}
for (AbstractEnemy enemy : tileMap.getEnemies()) {
if (enemy.getEnemyType()==EnemyTypeEnum.BOWSER) {
if (!enemy.isKilled()) {
bowser = enemy;
}
}
}
updateEnemies = true;
}
示例4: 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);
}
}
}
}
}
示例5: initTileset
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
/**
* Tiles that have a 'texture' property will be using an optimized tileset. This is to avoid screen tearing.
* @param layer
*/
private void initTileset(TiledMapTileLayer layer) {
ArrayMap<String, TextureRegion> textureArr = new ArrayMap<String, TextureRegion>();
for(int x = 0; x < layer.getWidth(); x++) {
for(int y = 0; y < layer.getHeight(); y++) {
Cell cell = layer.getCell(x, y);
if(cell != null) {
TiledMapTile oldTile = cell.getTile();
if(oldTile.getProperties().containsKey("texture")) {
//D.o("Initializing textures");
String texture = (String) oldTile.getProperties().get("texture");
if(textureArr.containsKey(texture)) {
oldTile.getTextureRegion().setRegion(textureArr.get(texture));
}
else {
TextureRegion t = Tiles.getTile(texture);
textureArr.put(texture, t);
oldTile.getTextureRegion().setRegion(t);
}
}
}
}
}
}
示例6: populateStateMap
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void populateStateMap(int x, int y, State state, int layerIndex, TiledMapTileLayer layer,
TiledMapConfig config) {
Cell cell = layer.getCell(x, y);
MapProperties layerProperties = layer.getProperties();
boolean collisionLayer = Boolean
.valueOf(layerProperties.get(config.get(Constants.COLLISION), "false", String.class));
CellState cellState = state.getState(x, y, layerIndex);
// Inherit the collision from the previous layer, if and only if
// the current layer is non-collision by default
if (layerIndex > 0 && !collisionLayer && state.getState(x, y, layerIndex - 1).isCollision()) {
cellState.setCollision(true);
} else if (cell != null) {
TiledMapTile tile = cell.getTile();
if (tile != null) {
MapProperties properties = tile.getProperties();
cellState.setProperties(properties);
if (properties.containsKey(Constants.COLLISION)) {
boolean collision = Boolean.valueOf(properties.get(Constants.COLLISION, String.class));
cellState.setCollision(collision);
} else {
cellState.setCollision(DEFAULT_COLLISION);
}
} else {
cellState.setCollision(DEFAULT_COLLISION);
}
} else {
cellState.setCollision(DEFAULT_COLLISION);
}
}
示例7: createBlocks
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
/**
* Creates box2d bodies for all non-null tiles
* in the specified layer and assigns the specified
* category bits.
*
* @param layer the layer being read
* @param bits category bits assigned to fixtures
*/
private void createBlocks(TiledMapTileLayer layer, short bits) {
// tile size
float ts = layer.getTileWidth();
// go through all cells in layer
for (int row = 0; row < layer.getHeight(); row++) {
for (int col = 0; col < layer.getWidth(); col++) {
// get cell
Cell cell = layer.getCell(col, row);
// check that there is a cell
if (cell == null) continue;
if (cell.getTile() == null) continue;
// create body from cell
BodyDef bdef = new BodyDef();
bdef.type = BodyType.StaticBody;
bdef.position.set((col + 0.5f) * ts / PPM, (row + 0.5f) * ts / PPM);
ChainShape cs = new ChainShape();
Vector2[] v = new Vector2[3];
v[0] = new Vector2(-ts / 2 / PPM, -ts / 2 / PPM);
v[1] = new Vector2(-ts / 2 / PPM, ts / 2 / PPM);
v[2] = new Vector2(ts / 2 / PPM, ts / 2 / PPM);
cs.createChain(v);
FixtureDef fd = new FixtureDef();
fd.friction = 0;
fd.shape = cs;
fd.filter.categoryBits = bits;
fd.filter.maskBits = B2DVars.BIT_PLAYER;
world.createBody(bdef).createFixture(fd);
cs.dispose();
}
}
}
示例8: generateBricks
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的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);
}
}
}
}
}
示例9: checkCollidingWithLayer
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的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;
}
示例10: generateMap
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
@Override
public IMap<T> generateMap(TiledMap map) {
tm = map;
mainLayer = (TiledMapTileLayer) tm.getLayers().get(RTSAbstractMap.BASE_LAYER_NAME);
mainLayerOverlay = (TiledMapTileLayer) tm.getLayers().get(RTSAbstractMap.BASE_LAYER_OVERLAY_NAME);
int columns = mainLayer.getWidth();
int rows = mainLayer.getHeight();
GridMap<T> gridMap = new GridMap<T>(columns, rows, (int) mainLayer.getTileWidth(),
(int) mainLayer.getTileHeight());
for (int col = 0; col < columns; col++) {
for (int row = 0; row < rows; row++) {
Cell cell = mainLayer.getCell(col, row);
String type = cell.getTile().getProperties().get(PROPERTY_TYPE, "undefined", String.class);
boolean shadow = Boolean.valueOf(cell.getTile().getProperties()
.get(PROPERTY_SHADOW, "false", String.class));
if (mainLayerOverlay != null) {
// Check if there's an overlay
Cell over = mainLayerOverlay.getCell(col, row);
if (over != null && over.getTile() != null) {
String typeaux = over.getTile().getProperties().get(PROPERTY_TYPE, "none", String.class);
if (!typeaux.equals("none")) {
type = typeaux;
}
if (Boolean.valueOf(over.getTile().getProperties().get(PROPERTY_SHADOW, "false", String.class))) {
shadow = true;
}
}
}
gridMap.getCell(col, row).setTerrainType(MapProperties.getTerrainType(type));
gridMap.getCell(col, row).setShadow(shadow);
gridMap.getCell(col, row).slopev = -Integer.valueOf(cell.getTile().getProperties()
.get(PROPERTY_SLOPEV, "0", String.class));
gridMap.getCell(col, row).slopeh = Integer.valueOf(cell.getTile().getProperties()
.get(PROPERTY_SLOPEH, "0", String.class));
}
}
generateHeights(gridMap);
return gridMap;
}
示例11: crearEnemigos
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void crearEnemigos() {
//crear los enemigos
for (int filas = 0; filas < en1.getHeight(); filas++){
for (int columnas = 0; columnas < en1.getWidth(); columnas++){
//obtener celda
Cell celda = en1.getCell(columnas, filas);
//asegurarse de que la celda exista
if(celda == null) continue;
if(celda.getTile() == null) continue;
//crear un enemigo para cada celda ocupada
enemy = new DatosEnemigos();
enemy.setPosX((columnas*GameWorld.ppt));
enemy.setPosY((filas*GameWorld.ppt)+4);
enemy.setColor(1);
listaenemigos.add(enemy);
}
}
}
示例12: crearLadrillos
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void crearLadrillos() {
int cont = 0;
for (int filas = 0; filas < ladrillo.getHeight(); filas++){
for (int columnas = 0; columnas < ladrillo.getWidth(); columnas++){
//obtener celda
Cell celda = ladrillo.getCell(columnas, filas);
//asegurarse de que la celda exista
if(celda == null) continue;
if(celda.getTile() == null) continue;
//crear un ladrillo a cada celda ocupada que coincida con espacio de ladrillo
if(espacios.get(cont)=="ladrillo"){
ladri = new InfoLadrillo();
ladri.setPosX((columnas*16)+8);
ladri.setPosY((filas*16));
ladri.setTienePowerUp(false);
ladri.setTienePuerta(false);
listaladrillos.add(ladri);
}
if(espacios.get(cont)=="powerup"){
ladri = new InfoLadrillo();
ladri.setPosX((columnas*16)+8);
ladri.setPosY((filas*16));
ladri.setTienePowerUp(true);
ladri.setTienePuerta(false);
listaladrillos.add(ladri);
}
if(espacios.get(cont)=="puerta"){
ladri = new InfoLadrillo();
ladri.setPosX((columnas*16)+8);
ladri.setPosY((filas*16));
ladri.setTienePowerUp(false);
ladri.setTienePuerta(true);
listaladrillos.add(ladri);
}
if(cont < espacios.size){
cont ++;
}
}
}
}
示例13: crearCemento
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入方法依赖的package包/类
private void crearCemento() {
//crear la colision de cada tile del suelo
BodyDef piso = new BodyDef();
FixtureDef fixDef = new FixtureDef();
piso.type = BodyType.StaticBody;
for (int filas = 0; filas < solido.getHeight(); filas++){
for (int columnas = 0; columnas < solido.getWidth(); columnas++){
//obtener celda
Cell celda = solido.getCell(columnas, filas);
//asegurarse de que la celda exista
if(celda == null) continue;
if(celda.getTile() == null) continue;
//crear un cuerpo y fixture a cada celda ocupada
piso.position.set((columnas*tileSize)+8/GameWorld.units,(filas*tileSize)+8/GameWorld.units);
PolygonShape shape =new PolygonShape();
shape.setAsBox(tileSize/2,tileSize/2);
fixDef.shape = shape;
fixDef.filter.categoryBits = GameWorld.BIT_PARED;
fixDef.filter.maskBits = GameWorld.BIT_ENEMIGOS | GameWorld.BIT_SENSOR | GameWorld.BIT_JUGADOR;
oTile = GameWorld.mundo.createBody(piso);
oTile.createFixture(fixDef).setUserData("solido");
}
}
}