本文整理匯總了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell方法的典型用法代碼示例。如果您正苦於以下問題:Java TiledMapTileLayer.Cell方法的具體用法?Java TiledMapTileLayer.Cell怎麽用?Java TiledMapTileLayer.Cell使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.maps.tiled.TiledMapTileLayer
的用法示例。
在下文中一共展示了TiledMapTileLayer.Cell方法的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);
}
}
}
}
}
示例2: 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);
}
}
}
}
}
}
示例3: 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;
}
示例4: removeEmptyLayers
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
private void removeEmptyLayers() {
Iterator<TiledMapTileLayer> layerIterator = layers.iterator();
while (layerIterator.hasNext()) {
TiledMapTileLayer layer = layerIterator.next();
boolean isEmpty = true;
for (Tile tile: objectTilesVectors) {
int x = tile.getX();
int y = tile.getY();
TiledMapTileLayer.Cell cell = layer.getCell(x, y);
if (cell == null) {
continue;
}
if (cell.getTile() != null) {
isEmpty = false;
break;
}
}
if (isEmpty) {
layerIterator.remove();
}
}
}
示例5: renderGrid
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public void renderGrid (int yMin, int yMax, int xMin, int xMax,
float halfTileWidth, float halfTileHeight, TiledMapTileLayer layer) {
spriteBatch.setColor(1, 1, 1, 0.3f);
TextureRegion texture = map.getGridTexture();
float width = map.getTileSizeX() * 2 * unitScaleX;
float height = map.getTileSizeY() * unitScaleY;
for (int row = yMax; row >= yMin; row--) {
for (int col = xMin; col <= xMax; col++) {
float x = (col * halfTileWidth) + (row * halfTileWidth);
float y = (row * halfTileHeight) - (col * halfTileHeight);
final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
if (cell == null) {
continue;
}
if (cell.getTile() != null && map.shouldRenderTile(col, row)) {
spriteBatch.draw(texture, x, y,width,height);
}
}
}
spriteBatch.setColor(1, 1, 1, 1);
}
示例6: 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()));
}
}
示例7: 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()));
}
}
示例8: createL0Animation
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public void createL0Animation(Texture tileTexture, String tag){
//hardcoded grass texture region
Tile = new Array<StaticTiledMapTile>();
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,0,0,32,32)));
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,32,0,32,32)));
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,64,0,32,32)));
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
for(int x = 0; x < layer.getWidth();x++){
for(int y = 0; y < layer.getHeight();y++){
TiledMapTileLayer.Cell cell = layer.getCell(x,y);
Object property = cell.getTile().getProperties().get(tag);
if(property != null){
cell.setTile(new AnimatedTiledMapTile(1.5f,Tile));
}
}
}
}
示例9: createL1SmallAnimation
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public void createL1SmallAnimation(Texture tileTexture, String tag){
//hardcoded grass texture region
Tile = new Array<StaticTiledMapTile>();
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,0,0,32,32)));
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,32,0,32,32)));
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,64,0,32,32)));
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1);
for(int x = 0; x < layer.getWidth();x++){
for(int y = 0; y < layer.getHeight();y++){
TiledMapTileLayer.Cell cell = layer.getCell(x,y);
if(cell!=null && cell.getTile().getProperties().get(tag)!=null){
cell.setTile(new AnimatedTiledMapTile(1.5f,Tile));
}
}
}
}
示例10: createL1LargeAnimation
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public void createL1LargeAnimation(Texture tileTexture, String tag){
//hardcoded grass texture region
Tile = new Array<StaticTiledMapTile>();
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,0,0,64,64)));
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,64,0,64,64)));
Tile.add(new StaticTiledMapTile(new TextureRegion(tileTexture,128,0,64,64)));
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1);
for(int x = 0; x < layer.getWidth();x++){
for(int y = 0; y < layer.getHeight();y++){
TiledMapTileLayer.Cell cell = layer.getCell(x,y);
if(cell!=null && cell.getTile().getProperties().get(tag)!=null){
cell.setTile(new AnimatedTiledMapTile(1.5f,Tile));
}
}
}
}
示例11: 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);
}
}
}
}
}
}
示例12: generate
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public void generate(Array<TiledMapTileLayer> layers, String propertyKey) {
for (int ty = 0; ty < height; ty++) {
for (int tx = 0; tx < width; tx++) {
v[ty][tx] = false;
}
}
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 && cell.getTile() != null && cell.getTile().getProperties().containsKey(propertyKey)) {
v[ty][tx] = true;
}
}
}
}
}
示例13: 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);
}
}
}
}
}
}
示例14: Tile
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public Tile(Vector2 cords, int tileWidth, int tileHeight, TileType type, TiledMapTileLayer.Cell cell) {
this.cords = cords;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.type = type;
this.cell = cell;
int tileCenterX = Math.round(cords.x) + tileWidth / 2;
int tileCenterY = Math.round(cords.y) + tileHeight / 2;
tileCenter = new Vector2(tileCenterX, tileCenterY);
}
示例15: getCell
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
* Gets the cell of a graphical map layer
* @param layerIndex the index of the map layer
* @return the cell
*/
protected TiledMapTileLayer.Cell getCell(int layerIndex) {
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(layerIndex);
return layer.getCell(
(int)(body.getPosition().x * MainGameClass.PPM / MainGameClass.TILE_PIXEL_SIZE),
(int)(body.getPosition().y * MainGameClass.PPM / MainGameClass.TILE_PIXEL_SIZE)
);
}