當前位置: 首頁>>代碼示例>>Java>>正文


Java MapLayer類代碼示例

本文整理匯總了Java中com.badlogic.gdx.maps.MapLayer的典型用法代碼示例。如果您正苦於以下問題:Java MapLayer類的具體用法?Java MapLayer怎麽用?Java MapLayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MapLayer類屬於com.badlogic.gdx.maps包,在下文中一共展示了MapLayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderAll

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
/**
 * Rendert alle Layer und alle Objekte
 *
 * @param deltaTime die Zeit, die seit dem letztem Frame vergangen ist
 */
public void renderAll(float deltaTime) {
    beginRender();
    for (MapLayer layer : map.getLayers()) {
        if (layer.isVisible()) {
            if (layer instanceof TiledMapTileLayer) {

                if (layer == displayLayer)
                    renderDisplayLayer((TiledMapTileLayer) layer, deltaTime);
                else
                    renderTileLayer((TiledMapTileLayer)layer);
            } else if (layer instanceof TiledMapImageLayer) {
                renderImageLayer((TiledMapImageLayer)layer);
            } else {
                renderObjects(layer);
            }
        }
    }
    endRender();
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:25,代碼來源:ExtendedOrthogonalTiledMapRenderer.java

示例2: update

import com.badlogic.gdx.maps.MapLayer; //導入依賴的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);
                    }
                }
            }
        }
    }
}
 
開發者ID:JayStGelais,項目名稱:jrpg-engine,代碼行數:23,代碼來源:TileAnimation.java

示例3: getCellPropertyFromTopMostTile

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
public static <T> T getCellPropertyFromTopMostTile(final TiledMap tiledMap, final TileCoordinate coordinate,
                                                   final String propertyName, final Class<T> clazz) {
    T value = null;
    for (MapLayer mapLayer : tiledMap.getLayers()) {
        if (mapLayer instanceof TiledMapTileLayer
                && matchProperty(mapLayer, GameMap.MAP_LAYER_PROP_MAP_LAYER, coordinate.getMapLayer())) {
            TiledMapTileLayer tiledMapTileLayer = (TiledMapTileLayer) mapLayer;
            TiledMapTileLayer.Cell cell = tiledMapTileLayer.getCell(coordinate.getX(), coordinate.getY());
            if (cell != null) {
                final MapProperties cellProps = cell.getTile().getProperties();
                value = (cellProps.get(propertyName, clazz) != null) ? cellProps.get(propertyName, clazz) : value;
            }
        }
    }

    return value;
}
 
開發者ID:JayStGelais,項目名稱:jrpg-engine,代碼行數:18,代碼來源:TiledUtil.java

示例4: load

import com.badlogic.gdx.maps.MapLayer; //導入依賴的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

示例5: renderLayersExcludingSpecial

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
protected void renderLayersExcludingSpecial(float delta) {
	for (MapLayer layer : map.getTiledMap().getLayers()) {

		boolean groundLayer = layer.getProperties().get(
				GameMapLoader.PROPERTY_GROUND_LAYER) != null;
		boolean collisionLayer = layer.getProperties().get(
				GameMapLoader.PROPERTY_COLISIONS_LAYER) != null;
		boolean objectLayer = layer.getProperties().get(
				GameMapLoader.PROPERTY_OBJECT_LAYER) != null;
		boolean overheadLayer = layer.getProperties().get(
				GameMapLoader.PROPERTY_OVERHEAD_LAYER) != null;
		boolean alwaysAboveLayer = layer.getProperties().get(
				GameMapLoader.PROPERTY_ALWAYSABOVE_LAYER) != null;

		if (groundLayer || collisionLayer || objectLayer || overheadLayer || alwaysAboveLayer) {
			continue;
		}
		if (layer.isVisible()) {
			if (layer instanceof TiledMapTileLayer) {
				renderTileLayer(delta, (TiledMapTileLayer) layer);
			}
		}
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:25,代碼來源:GameMapRenderer.java

示例6: loadCharacterGroups

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
private void loadCharacterGroups() throws IOException {
	MapLayer groupsLayer = map.getLayers().get(LAYER_GROUPS);
	if (groupsLayer == null) {
		return;
	}
	MapObjects groups = groupsLayer.getObjects();
	for (MapObject mapGroup : groups) {
		if (mapGroup.getName() == null) {
			continue;
		}
		String groupFile = mapGroup.getName();
		String id = (String) mapGroup.getProperties().get(PROPERTY_ID);
		if (id == null) {
			id = groupFile;
		}

		Vector2 position = getPositionFromMapObject(mapGroup);
		CharacterGroupGameObject group = new CharacterGroupGameObject(id, Gdx.files.internal(Configuration
				.getFolderGroups() + groupFile + ".xml"), gameMap);
		group.position().set((int) (position.x / gameMap.getTileSizeX()),
				(int) (position.y / gameMap.getTileSizeY()));
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:24,代碼來源:GameMapLoader.java

示例7: loadItems

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
private void loadItems() throws IOException {
	MapLayer itemsLayer = map.getLayers().get(LAYER_ITEMS);
	if (itemsLayer == null) {
		return;
	}
	MapObjects items = itemsLayer.getObjects();
	for (MapObject item : items) {
		Vector2 position = getPositionFromMapObject(item);
		PickableGameObject newItem = new PickableGameObject(item.getName());
		newItem.getOwner().set(item.getProperties().get(PROPERTY_OWNER_CHARACTER, String.class),
				Faction.getFaction(item.getProperties().get(PROPERTY_OWNER_FACTION, String.class)),
				Boolean.valueOf(item.getProperties().get(PROPERTY_OWNER_FIXED, "false", String.class)));
		newItem.position().set(position.x / gameMap.getTileSizeX(), position.y / gameMap.getTileSizeY());
		newItem.setMap(gameMap);
		newItem.setOffsets(newItem.getXOffset() + getInteger(item, PROPERTY_XOFFSET, 0) * gameMap.getScaleX(),
				newItem.getYOffset() + getInteger(item, PROPERTY_YOFFSET, 0) * gameMap.getScaleY());
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:19,代碼來源:GameMapLoader.java

示例8: loadLocations

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
private void loadLocations(MapLayer locationsLayer, boolean loadTraps) throws IOException {
	if (locationsLayer == null) {
		return;
	}
	MapObjects locations = locationsLayer.getObjects();
	for (MapObject location : locations) {
		String locId = location.getProperties().get(PROPERTY_ID, location.getName(), String.class)
				.toLowerCase(Locale.ENGLISH);
		String locType = location.getName();
		SaveablePolygon locPolygon = transformTiledPolygon(gameMap, getPolygonFromMapObject(location));
		GameLocation newLocation = loadTraps ? new TrapLocation(locId, locType, locPolygon,
				Boolean.valueOf(location.getProperties().get(PROPERTY_DETECTED, "false", String.class)),
				Boolean.valueOf(location.getProperties().get(PROPERTY_DISARMED, "false", String.class)))
				: new GameLocation(locId, locType, locPolygon);
		newLocation.setMap(gameMap);
		newLocation.loadFromXML(Gdx.files.internal(Configuration.getFolderLocations() + locType + ".xml"));
	}

	for (GameObject go : gameMap.gameObjects) {
		if (go instanceof GameCharacter) {
			((GameCharacter) go).calculateCurrentLocations();
		}
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:25,代碼來源:GameMapLoader.java

示例9: loadTransitions

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
private void loadTransitions() {
	MapLayer locationsLayer = map.getLayers().get(LAYER_TRANSITIONS);
	if (locationsLayer == null) {
		return;
	}
	Array<Transition> transitions = new Array<Transition>();
	MapObjects locations = locationsLayer.getObjects();
	for (MapObject location : locations) {
		MapObject mapObject = (MapObject) location;
		String[] coords = ((String) mapObject.getProperties().get(PROPERTY_TARGET)).split(",");
		Tile target = new Tile(Integer.parseInt(coords[0].trim()), Integer.parseInt(coords[1].trim()));

		Polygon polygon = getPolygonFromMapObject(mapObject);
		Transition newTransition = new Transition(gameMap, mapObject.getName(), target.getX(), target.getY(),
				transformTiledPolygon(gameMap, polygon));
		transitions.add(newTransition);
	}
	buildTransitionTiles(transitions);
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:20,代碼來源:GameMapLoader.java

示例10: populate

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
public void populate(TiledMap tiledMap, State state, Camera camera, MapLayerRendererFactory rendererFactory,
      TiledMapConfig config) {
   MapLayers mapLayers = tiledMap.getLayers();
   handleMapProperties(tiledMap.getProperties(), state, config);
   List<String> layerIds = new ArrayList<String>();
   int lastTileLayerIndex = 0;
   for (int i = 0; i < mapLayers.getCount(); ++i) {
      MapLayer mapLayer = mapLayers.get(i);
      if (mapLayer instanceof TiledMapTileLayer) {
         if (i > 0) {
            lastTileLayerIndex++;
         }
         String layerId = handleTiledMapTileLayer((TiledMapTileLayer) mapLayer, i, tiledMap, camera, rendererFactory,
               config);
         layerIds.add(layerId);
         populateStaticMapData(lastTileLayerIndex, (TiledMapTileLayer) mapLayer, state, config);
      } else {
         // Not a tiledlayer so consider it as an object layer
         handleObjectLayer(lastTileLayerIndex, mapLayer, state, config);
      }
   }
   state.setLayerIds(layerIds);
}
 
開發者ID:bitbrain,項目名稱:braingdx,代碼行數:24,代碼來源:StatePopulator.java

示例11: getHierarchy

import com.badlogic.gdx.maps.MapLayer; //導入依賴的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

示例12: loadLevelObjects

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
public void loadLevelObjects() {
	MapLayer mapLayerMission = getMap().getLayers().get(LAYER_MISSIONOBJECTS);
	
	MapObjects objects = mapLayerMission.getObjects();
	
	for (int i = 0; i < objects.getCount(); i++) {
		MapObject mapObj = objects.get(i);
		
		SpawnableBase base = EntityFactory.getEntity(mapObj.getName());
		if (base != null) {
			base.prepareFromMap(getLevelID(), mapObj);
		}
	}
	
	Logger.dbg("map objects loaded!");
}
 
開發者ID:Corosauce,項目名稱:AI_TestBed_v3,代碼行數:17,代碼來源:Level.java

示例13: renderFG

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
public void renderFG(SpriteBatch sb){
		sb.begin();
			if(foreground!=null)
				sb.draw(foreground, 0, 0);
//			sb.draw(weather,0,0);	//if raining or foggy
		sb.end();
		
		try{
			for(MapLayer t : tileMap.getLayers())
				if(t.getName().equals("fg")){
					t.setVisible(true);
				}
				else t.setVisible(false);
			
			tmr.render();
			
		}catch(Exception e){ 
			e.printStackTrace();
		}
	}
 
開發者ID:JayKEm,項目名稱:Aftamath,代碼行數:21,代碼來源:Scene.java

示例14: render

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
public void render(){
    beginRender();
    int layerCourant = 0;
    for(MapLayer layer : map.getLayers()){
        if(layer instanceof TiledMapTileLayer){
            renderTileLayer((TiledMapTileLayer)layer);
            layerCourant++;
            if(layerCourant==numberOfSpriteLayer){//if we are in the layer for the Sprite
                //just draw it up!!!!

                for(Sprite dropOfKoffee : superStrongKoffee){
                    System.out.println("Fuck OFFF!!!!");
                    dropOfKoffee.draw(this.batch);
                }
            }
        }else{
            for(MapObject wtfIsThisObject : layer.getObjects()){
                renderObject(wtfIsThisObject);
            }
        }
    }
    endRender();
}
 
開發者ID:naomiHauret,項目名稱:OdysseeDesMaths,代碼行數:24,代碼來源:OrthogonalTiledMapRendererWithKoffee.java

示例15: loadObjectGroup

import com.badlogic.gdx.maps.MapLayer; //導入依賴的package包/類
protected void loadObjectGroup (TiledMap map, Element element) {
	if (element.getName().equals("objectgroup")) {
		String name = element.getAttribute("name", null);
		MapLayer layer = new MapLayer();
		layer.setName(name);
		Element properties = element.getChildByName("properties");
		if (properties != null) {
			loadProperties(layer.getProperties(), properties);
		}

		for (Element objectElement : element.getChildrenByName("object")) {
			loadObject(layer, objectElement);
		}

		map.getLayers().add(layer);
	}
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:18,代碼來源:BaseTmxMapLoader.java


注:本文中的com.badlogic.gdx.maps.MapLayer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。