本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMap.getTileSets方法的典型用法代码示例。如果您正苦于以下问题:Java TiledMap.getTileSets方法的具体用法?Java TiledMap.getTileSets怎么用?Java TiledMap.getTileSets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.maps.tiled.TiledMap
的用法示例。
在下文中一共展示了TiledMap.getTileSets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tilesetNameFromTileId
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
/** Returns the tileset name associated with the specified tile id
* @return a tileset name */
private String tilesetNameFromTileId (TiledMap map, int tileid) {
String name = "";
if (tileid == 0) {
return "";
}
for (TiledMapTileSet tileset : map.getTileSets()) {
int firstgid = tileset.getProperties().get("firstgid", -1, Integer.class);
if (firstgid == -1) continue; // skip this tileset
if (tileid >= firstgid) {
name = tileset.getName();
} else {
return name;
}
}
return name;
}
示例2: loadNavigationLayer
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的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);
}
示例3: Map
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
public Map(int levelNo, int tileSize){
setPosition(0, 0);
setOrigin(0, 0);
TiledMap map = Asset.map(levelNo);
this.tileSize = tileSize;
mlayers = map.getLayers();
tileSets = map.getTileSets();
}