当前位置: 首页>>代码示例>>Java>>正文


Java TiledMap.getProperties方法代码示例

本文整理汇总了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;
            }
        }
    }
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:24,代码来源:MapActionHandler.java

示例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);
        }
    }
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:15,代码来源:CollisionDetector.java

示例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;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:12,代码来源:Assets.java

示例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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:13,代码来源:GameMap.java

示例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");
   }
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:16,代码来源:TiledMapManagerImpl.java

示例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;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:57,代码来源:KyperMapLoader.java


注:本文中的com.badlogic.gdx.maps.tiled.TiledMap.getProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。