• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Map类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.badlogic.gdx.maps.Map的典型用法代码示例。如果您正苦于以下问题:Java Map类的具体用法?Java Map怎么用?Java Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Map类属于com.badlogic.gdx.maps包,在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getHierarchy

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * @param map the {@link Map} which hierarchy to print
 * @return a human readable {@link String} containing the hierarchy of the {@link com.badlogic.gdx.maps.MapObjects} of the given {@link Map}
 */
public String getHierarchy(Map map) {
    String hierarchy = map.getClass().getName() + "\n", key, layerHierarchy;

    Iterator<String> keys = map.getProperties().getKeys();
    while (keys.hasNext())
        hierarchy += (key = keys.next()) + ": " + map.getProperties().get(key) + "\n";

    for (MapLayer layer : map.getLayers()) {
        hierarchy += "\t" + layer.getName() + " (" + layer.getClass().getName() + "):\n";
        layerHierarchy = getHierarchy(layer).replace("\n", "\n\t\t");
        layerHierarchy = layerHierarchy.endsWith("\n\t\t") ? layerHierarchy.substring(0, layerHierarchy.lastIndexOf("\n\t\t")) : layerHierarchy;
        hierarchy += !layerHierarchy.equals("") ? "\t\t" + layerHierarchy : layerHierarchy;
    }

    return hierarchy;
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:21,代码来源:Box2DMapObjectParser.java


示例2: loadObjects

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * Load the objects from the tmx file, convert them into textures and put them on the layer.
 */
private void loadObjects() {
	//TODO Use a spritesheet for the background objects
	Map map = world.getMap();
	Iterator<MapObject> it = map.getLayers().get(layer_name).getObjects().iterator();
	while(it.hasNext()) {
		MapObject obj = it.next();
		String file = "data/backgrounds/" + (String) obj.getProperties().get("src");
		layer_objects.add(obj);
		if(!layer_textures.containsKey(file)) {
			Texture texture = new Texture(file);
			texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
			layer_textures.put(file, texture);
		}
	}
}
 
开发者ID:arjanfrans,项目名称:mario-game,代码行数:19,代码来源:ParallaxLayer.java


示例3: getHierarchy

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * @param map the {@link Map} which hierarchy to print
 * @return a human readable {@link String} containing the hierarchy of the {@link MapObjects} of the given {@link Map}
 */
public String getHierarchy(Map map) {
    String hierarchy = map.getClass().getName() + "\n", key, layerHierarchy;

    Iterator<String> keys = map.getProperties().getKeys();
    while (keys.hasNext())
        hierarchy += (key = keys.next()) + ": " + map.getProperties().get(key) + "\n";

    for (MapLayer layer : map.getLayers()) {
        hierarchy += "\t" + layer.getName() + " (" + layer.getClass().getName() + "):\n";
        layerHierarchy = getHierarchy(layer).replace("\n", "\n\t\t");
        layerHierarchy = layerHierarchy.endsWith("\n\t\t") ? layerHierarchy.substring(0, layerHierarchy.lastIndexOf("\n\t\t")) : layerHierarchy;
        hierarchy += !layerHierarchy.equals("") ? "\t\t" + layerHierarchy : layerHierarchy;
    }

    return hierarchy;
}
 
开发者ID:Rubentxu,项目名称:DreamsLibGdx,代码行数:21,代码来源:Box2DMapObjectParser.java


示例4: load

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * creates the given {@link Map Map's} {@link com.badlogic.gdx.maps.MapObjects} in the given {@link World}
 *
 * @param world the {@link World} to create the {@link com.badlogic.gdx.maps.MapObjects} of the given {@link Map} in
 * @param map   the {@link Map} which {@link com.badlogic.gdx.maps.MapObjects} to create in the given {@link World}
 * @return the given {@link World} with the parsed {@link com.badlogic.gdx.maps.MapObjects} of the given {@link Map} created in it
 */
public World load(World world, Map map) {
    if (!ignoreMapUnitScale)
        unitScale = getProperty(map.getProperties(), aliases.unitScale, unitScale);
    box2dObjectFactory.setUnitScale(unitScale);
    tileWidth = getProperty(map.getProperties(), "tilewidth", (int) tileWidth);
    tileHeight = getProperty(map.getProperties(), "tileheight", (int) tileHeight);

    for (MapLayer mapLayer : map.getLayers())
        load(world, mapLayer);

    return world;
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:20,代码来源:Box2DMapObjectParser.java


示例5: createDropOffPoints

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
private void createDropOffPoints(Map map){
	logger.debug("Creating DropOffPoints");
	
	String layerName = "dropoff";
	
	//dropOffPoint map layer
	MapLayer layer = map.getLayers().get(layerName);
	if (layer == null) {
		logger.error("layer " + layerName + " does not exist");
		return;
	}

	//Layer objects
	MapObjects objects = layer.getObjects();
	for (MapObject mapObj : objects){
		
		//Object properties. 
		//name and position are set by the tiled editor. The rest are custom properties
		Vector2 position = new Vector2();
		float range = 1;
				
		MapProperties prop = mapObj.getProperties();
		Object x = prop.get("x"),
			   y = prop.get("y"),
			   r = prop.get("range");
		
		if (r != null) range = Float.parseFloat(r.toString());
		if (x != null && y != null)
			position.set((Float)x,(Float)y).scl(1/App.engine.PIXELS_PER_METER);					  
		App.engine.systems.dropoff.add(new DropOffPoint(position,range)); 	
	}		
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:33,代码来源:Level.java


示例6: createEntities

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
private void createEntities(Map map) {

	logger.debug("Creating Entities");
	String layerName = "entities";
	
	MapLayer layer = map.getLayers().get(layerName);
	if (layer == null) {
		logger.error("layer " + layerName + " does not exist");
		return;
	}

	//Entity objects
	Vector2 position = new Vector2(),
	velocity = new Vector2();
	
	MapObjects objects = layer.getObjects();
	for (MapObject mapObj : objects){

		MapProperties prop = mapObj.getProperties();
		Object x = prop.get("x"),
			   y = prop.get("y"),
			   vx = prop.get("vx"),
			   vy = prop.get("vy");
		
		position.set(0,0);
		velocity.set(0,0);
		
		if (x != null && y != null)	
			position.set((Float)x,(Float)y).scl(1/App.engine.PIXELS_PER_METER);
		if (vx != null && y != null)
			velocity.set((Float)vx,(Float)vy);
		logger.debug(" -Create: " + mapObj.getName());
		Entity e = App.engine.factory.build(mapObj.getName(),position,velocity);
		if (mapObj.getName().equals("player")) App.engine.systems.player.setPlayer(e);
	}
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:37,代码来源:Level.java


示例7: drawBackground

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
private void drawBackground(SpriteBatch batch, float posX, float posY) {
	batch.begin();
	Map map = world.getMap();
	int width = (Integer) map.getProperties().get("width");
	//getTexture("big_mountain").getWidth() * 
	batch.draw(background_image , -16 ,0 , width * 16, 16);
	batch.end();
}
 
开发者ID:arjanfrans,项目名称:mario-game,代码行数:9,代码来源:WorldRenderer.java


示例8: load

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * creates the given {@link Map Map's} {@link MapObjects} in the given {@link World}
 *
 * @param world the {@link World} to create the {@link MapObjects} of the given {@link Map} in
 * @param map   the {@link Map} which {@link MapObjects} to create in the given {@link World}
 * @return the given {@link World} with the parsed {@link MapObjects} of the given {@link Map} created in it
 */
public World load(World world, Map map) {
    if (!ignoreMapUnitScale)
        unitScale = getProperty(map.getProperties(), aliases.unitScale, unitScale);
    box2dObjectFactory.setUnitScale(unitScale);
    tileWidth = getProperty(map.getProperties(), "tilewidth", (int) tileWidth);
    tileHeight = getProperty(map.getProperties(), "tileheight", (int) tileHeight);

    for (MapLayer mapLayer : map.getLayers())
        load(world, mapLayer);

    return world;
}
 
开发者ID:Rubentxu,项目名称:DreamsLibGdx,代码行数:20,代码来源:Box2DMapObjectParser.java


示例9: createSpawnZones

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
private void createSpawnZones(Map map){
	logger.debug("Creating SpawnPoints");
	
	String layerName = "spawn";
	
	//spawnPoint map layer
	MapLayer layer = map.getLayers().get(layerName);
	if (layer == null) {
		logger.error("layer " + layerName + " does not exist");
		return;
	}

	//Layer objects
	float units = App.engine.PIXELS_PER_METER;
	MapObjects objects = layer.getObjects();
	for (MapObject mapObj : objects){
		logger.debug("found spawn zone");
		//Spawn area rectangle
		Rectangle rect;
		
		if (mapObj instanceof RectangleMapObject){
			rect = ((RectangleMapObject) mapObj).getRectangle();
			rect.height /= units;
			rect.width /= units;
			rect.x /= units;
			rect.y /= units;			
		}
		else {
			logger.error("spawn zones should only be rectangles");
			continue;
		}
		
		//Object properties. 
		//name and position are set by the tiled editor. The rest are custom properties
		String 	name = mapObj.getName();
		int 	maximum = 0;
		float 	delay = 3;
		
		logger.debug("Creating '" + name + "' spawn zone");
		
		MapProperties prop = mapObj.getProperties();
		Object max = prop.get("maximum"),
			   dly = prop.get("delay");
		
		if (max != null) maximum = Integer.parseInt(max.toString());
		if (dly != null) delay = Float.parseFloat(dly.toString());
		SpawnSystem spawner = App.engine.systems.spawn;
		spawner.add(new SpawnZone(rect,name,maximum,delay)); 	
	}		
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:51,代码来源:Level.java


示例10: createPhysics

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * @param map will use the "physics" layer of this map to look for shapes in order to create the static bodies.
 */
public void createPhysics(Map map) {
	createPhysics(map, "physics");
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:7,代码来源:MapBodyManager.java


示例11: LevelPhysicsProcessor

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
public LevelPhysicsProcessor(final World world, final Map map, final float unitScale) {
	b2dRenderer = new Box2DDebugRenderer();
	mapObjectListener = new Box2DMapObjectListener();
	Box2DMapObjectParser objectParser = new Box2DMapObjectParser(mapObjectListener, unitScale);
	objectParser.load(world, map);
}
 
开发者ID:nfantone,项目名称:ninja-rabbit,代码行数:7,代码来源:LevelPhysicsProcessor.java


示例12: Level

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
public Level(Map map) {
	this.map = map;

	MapLayer collisionLayer = map.getLayers().get("Collision");
	collisionObjects = collisionLayer.getObjects();
}
 
开发者ID:sftrabbit,项目名称:Interplanar,代码行数:7,代码来源:Level.java


示例13: fromMapPath

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
public static Level fromMapPath(String filePath) {
	Map map = new TmxMapLoader().load(filePath);

	return new Level(map);
}
 
开发者ID:sftrabbit,项目名称:Interplanar,代码行数:6,代码来源:Level.java


示例14: B2DWorldCreator

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * B2DWorldCreator's constructor.
 * In loads the given map to the given world.
 *
 * @param world World to were the map elements will be loaded.
 * @param map   Map to load the world elements from.
 */
public B2DWorldCreator(World world, Map map) {
    this.world = world;
    this.map = map;

    addLayerLoaders();
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:14,代码来源:B2DWorldCreator.java


示例15: createPhysics

import com.badlogic.gdx.maps.Map; //导入依赖的package包/类
/**
 * @param map
 *            will use the "physics" layer of this map to look for shapes in
 *            order to create the static bodies.
 */
public void createPhysics(Map map) {
	createPhysics(map, "physics");
}
 
开发者ID:LostCodeStudios,项目名称:JavaLib,代码行数:9,代码来源:MapBodyManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Activator类代码示例发布时间:2022-05-22
下一篇:
Java BasicPasswordEncryptor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap