本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMap.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java TiledMap.getProperties方法的具体用法?Java TiledMap.getProperties怎么用?Java TiledMap.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.maps.tiled.TiledMap
的用法示例。
在下文中一共展示了TiledMap.getProperties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
public void load(TiledMap map) {
MapProperties properties = map.getProperties();
width = (Integer) properties.get(Tmx.WIDTH);
height = (Integer) properties.get(Tmx.HEIGHT);
objects = new MapObject[width][height];
portals.clear();
for (MapLayer layer : map.getLayers()) {
for (MapObject object : layer.getObjects()) {
if (object.getProperties().get("portal-id") != null) {
portals.put((String) object.getProperties().get("portal-id"), object);
}
MapProperties objectProperties = object.getProperties();
float x = (Float) objectProperties.get("x");
float y = (Float) objectProperties.get("y");
int indexX = (int) Math.floor(x / GameConfig.CELL_SCALE);
int indexY = (int) Math.floor(y / GameConfig.CELL_SCALE);
if (indexX >= 0 && indexY >= 0 && indexX < width && indexY < height) {
objects[indexX][indexY] = object;
}
}
}
}
示例2: updateCollisions
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
public void updateCollisions(TiledMap map) {
MapProperties properties = map.getProperties();
width = (Integer) properties.get(Tmx.WIDTH);
height = (Integer) properties.get(Tmx.HEIGHT);
if (collisions != null) {
collisions = null;
}
collisions = new boolean[width][height];
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
collisions[x][y] = getCollision(map, x, y);
}
}
}
示例3: AssetTiledMap
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
public AssetTiledMap(TiledMap currentTileMap){
tiledMap = currentTileMap;
MapProperties props = currentTileMap.getProperties();
mapName = props.get("mapName",String.class);
mapTileWidth = props.get("width",Integer.class);
mapTileHeight = props.get("height",Integer.class);
tileWidth = props.get("tilewidth",Integer.class);
tileHeight = props.get("tileheight",Integer.class);
mapPixelWidth = mapTileWidth * tileWidth;
mapPixelHeight = mapTileHeight * tileHeight;
}
示例4: setTiledMap
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
void setTiledMap (TiledMap map) {
this.tiledMap = map;
MapProperties props = map.getProperties();
this.tileSizeX = Float.valueOf(props.get("tilewidth").toString());
this.tileSizeY = Float.valueOf(props.get("tileheight").toString());
this.isIsometric = "isometric".equals(props.get("orientation", String.class));
if (isIsometric) {
tileSizeX /= 2;
}
this.isWorldMap = props.get("worldMap", String.class) != null;
this.isInterior = props.get("interior", String.class) != null;
}
示例5: validate
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
private void validate(TiledMap map) throws TiledMapException {
MapProperties properties = map.getProperties();
if (properties.get(Constants.WIDTH) == null) {
throw new TiledMapException("Map has no width specified");
}
if (properties.get(Constants.HEIGHT) == null) {
throw new TiledMapException("Map has no width specified");
}
if (properties.get(Constants.WIDTH, int.class) <= 0f) {
throw new TiledMapException("Map width must be larger than 0");
}
if (properties.get(Constants.HEIGHT, int.class) <= 0f) {
throw new TiledMapException("Map height must be larger than 0");
}
}
示例6: loadMap
import com.badlogic.gdx.maps.tiled.TiledMap; //导入方法依赖的package包/类
protected TiledMap loadMap(Element root, FileHandle tmxFile, AtlasResolver resolver) {
TiledMap map = new TiledMap();
String mapOrientation = root.getAttribute("orientation", null);
int mapWidth = root.getIntAttribute("width", 0);
int mapHeight = root.getIntAttribute("height", 0);
int tileWidth = root.getIntAttribute("tilewidth", 0);
int tileHeight = root.getIntAttribute("tileheight", 0);
String mapBackgroundColor = root.getAttribute("backgroundcolor", null);
MapProperties mapProperties = map.getProperties();
if (mapOrientation != null) {
mapProperties.put("orientation", mapOrientation);
}
mapProperties.put("width", mapWidth);
mapProperties.put("height", mapHeight);
mapProperties.put("tilewidth", tileWidth);
mapProperties.put("tileheight", tileHeight);
if (mapBackgroundColor != null) {
mapProperties.put("backgroundcolor", mapBackgroundColor);
}
mapTileWidth = tileWidth;
mapTileHeight = tileHeight;
mapWidthInPixels = mapWidth * tileWidth;
mapHeightInPixels = mapHeight * tileHeight;
if (mapOrientation != null) {
if ("staggered".equals(mapOrientation)) {
if (mapHeight > 1) {
mapWidthInPixels += tileWidth / 2;
mapHeightInPixels = mapHeightInPixels / 2 + tileHeight / 2;
}
}
}
for (int i = 0, j = root.getChildCount(); i < j; i++) {
Element element = root.getChild(i);
String elementName = element.getName();
if (elementName.equals("properties")) {
loadProperties(map.getProperties(), element);
String types_path = "kyperbox_types.xml";
if (types == null) {
types = new TiledObjectTypes(types_path);
templates = new TiledTemplates(types, "");
}
} else if (elementName.equals("tileset")) {
loadTileset(map, element, tmxFile, resolver);
} else if (elementName.equals("layer")) {
loadTileLayer(map, map.getLayers(), element);
} else if (elementName.equals("objectgroup")) {
loadObjectGroup(map, map.getLayers(), element);
}
}
return map;
}