本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMapTile.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java TiledMapTile.getProperties方法的具体用法?Java TiledMapTile.getProperties怎么用?Java TiledMapTile.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.maps.tiled.TiledMapTile
的用法示例。
在下文中一共展示了TiledMapTile.getProperties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.badlogic.gdx.maps.tiled.TiledMapTile; //导入方法依赖的package包/类
@Override
protected void initialize() {
super.initialize();
cableMask = mapSystem.getMask("cable-type");
for (TiledMapTileSet tileSet : mapSystem.map.getTileSets()) {
for (TiledMapTile tile : tileSet) {
MapProperties properties = tile.getProperties();
if (properties.containsKey("cable-type")) {
if ((Boolean) properties.get("cable-state")) {
tilesOn.put((Integer) properties.get("cable-type"), tile);
} else {
tilesOff.put((Integer) properties.get("cable-type"), tile);
}
}
}
}
}
示例2: update
import com.badlogic.gdx.maps.tiled.TiledMapTile; //导入方法依赖的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: fromTileMapTile
import com.badlogic.gdx.maps.tiled.TiledMapTile; //导入方法依赖的package包/类
/**
* Creates a {@link Tile} from a {@link TiledMapTile}.
*
* @param tiledMapTile the tiledMapTile from which to read from
* @param x coordinate
* @param y coordinate
* @return the created Tile
*/
public static Tile fromTileMapTile(TiledMapTile tiledMapTile, int x, int y) {
MapProperties mapProperties = tiledMapTile.getProperties();
Tile tile = new Tile(x, y);
if (mapProperties.get("untraversable") != null)
tile.setTraversable(mapProperties.get("untraversable", Boolean.class));
return tile;
}
示例4: findTileFrames
import com.badlogic.gdx.maps.tiled.TiledMapTile; //导入方法依赖的package包/类
private void findTileFrames() {
for (TiledMapTileSet tileSet : tiledMap.getTileSets()) {
for (TiledMapTile tile : tileSet) {
final MapProperties tileProperties = tile.getProperties();
if (tileProperties.containsKey(JRPG_TILE_ANIMATION_ID)
&& tileProperties.get(JRPG_TILE_ANIMATION_ID).equals(id)) {
tileFrames.put(tileProperties.get(JRPG_TILE_ANIMATION_INDEX, Integer.class), tile);
}
}
}
}
示例5: populateStateMap
import com.badlogic.gdx.maps.tiled.TiledMapTile; //导入方法依赖的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);
}
}
示例6: loadNavigationLayer
import com.badlogic.gdx.maps.tiled.TiledMapTile; //导入方法依赖的package包/类
private void loadNavigationLayer(TiledMap map, Element element, String layerName){
int width = element.getIntAttribute("width", 0);
int height = element.getIntAttribute("height", 0);
int[] ids = getTileIds(element, width, height);
TiledMapTileSets tilesets = map.getTileSets();
GridCell[][] nodes = new GridCell[width][height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int id = ids[y * width + x];
TiledMapTile tile = tilesets.getTile(id & ~MASK_CLEAR);
GridCell cell = new GridCell(x, height - 1 - y, false);
if (tile != null) {
MapProperties tileProp = tile.getProperties();
String walkableProp = tileProp.get(navigationProperty, navigationClosedValue, String.class);
cell.setWalkable( !walkableProp.equals(navigationClosedValue) );
}
nodes[cell.getX()][cell.getY()] = cell;
}
}
NavigationTiledMapLayer layer = new NavigationTiledMapLayer(nodes);
layer.setName(layerName);
layer.setVisible(false);
Element properties = element.getChildByName("properties");
if (properties != null) {
loadProperties(layer.getProperties(), properties);
}
map.getLayers().add(layer);
}