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


Java MapLayers.get方法代码示例

本文整理汇总了Java中com.badlogic.gdx.maps.MapLayers.get方法的典型用法代码示例。如果您正苦于以下问题:Java MapLayers.get方法的具体用法?Java MapLayers.get怎么用?Java MapLayers.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.maps.MapLayers的用法示例。


在下文中一共展示了MapLayers.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populate

import com.badlogic.gdx.maps.MapLayers; //导入方法依赖的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

示例2: RTSAbstractMap

import com.badlogic.gdx.maps.MapLayers; //导入方法依赖的package包/类
public RTSAbstractMap(RTSGame game, String tiledMapPath, boolean useFogOfWar) {
super();
this.game = game;

// Lets initialize the tiled map
tiledMap = new TmxMapLoader().load(tiledMapPath);

MapLayers mapLayers = tiledMap.getLayers();
baseLayer = (TiledMapTileLayer) mapLayers.get(BASE_LAYER_NAME);
baseLayerOverlay = (TiledMapTileLayer) mapLayers.get(BASE_LAYER_OVERLAY_NAME);
MapLayer objectsLayer = mapLayers.get(OBJECTS_LAYER_NAME);
if (objectsLayer != null)
    mapObjects = objectsLayer.getObjects();

mapBatch = new SpriteBatch(100, RTSGame.game.mapShader);

// Initialize map renderer
mapRenderer = new OrthogonalTiledMapRenderer(tiledMap, mapBatch);

initializeMapGenAndRenderer();

// And now let's initialize the quadtree
map = mapGen.generateMap(tiledMap);

astar = new AStar<IBoundsObject>(map);

// Number of tiles that fit in the canvas, to render.
renderTileWidth = Gdx.graphics.getWidth() / (int) baseLayer.getTileWidth();
renderTileHeight = Gdx.graphics.getHeight() / (int) baseLayer.getTileHeight();

// Fog of war
this.useFogOfWar = useFogOfWar;
if (useFogOfWar) {
    fogOfWar = new FogOfWar((int) (baseLayer.getWidth()), (int) (baseLayer.getHeight()),
	    (int) baseLayer.getTileWidth());
}
   }
 
开发者ID:langurmonkey,项目名称:rts-engine,代码行数:38,代码来源:RTSAbstractMap.java

示例3: generateCollisionMap

import com.badlogic.gdx.maps.MapLayers; //导入方法依赖的package包/类
/**
 * <p>
 * Creates and returns a new {@link TerrainCollisionMap} from the given map.
 * If the map is not a valid Möbius map, the behaviour is undefined.
 * </p>
 * 
 * @param map
 *        The map from which to create a TerrainCollisionMap.
 * @return
 */
public static TerrainCollisionMap generateCollisionMap(TiledMap map, TiledMap mirrorMap) {
	TerrainCollisionMap retVal = null;

	MapLayers layers = map.getLayers();
	MapLayers mirrorLayers = mirrorMap.getLayers();

	TiledMapTileLayer egLayer = (TiledMapTileLayer) layers.get(0);
	HashMap<TiledMapTileLayer, PlatformManipulationHandler> platformLayers = new HashMap<TiledMapTileLayer, PlatformManipulationHandler>();

	ArrayList<Integer> collisionArray = null;

	for (int i = 0; i < layers.getCount(); i++) {
		TiledMapTileLayer origLayer = (TiledMapTileLayer) layers.get(i);
		TiledMapTileLayer mirrorLayer = (TiledMapTileLayer) mirrorLayers.get(i);

		if ((LevelEntityFactory.isSolidLayer(origLayer) && LevelEntityFactory.isSolidLayer(mirrorLayer))
				|| (LevelEntityFactory.isInteractableLayer(origLayer) && LevelEntityFactory
						.isInteractableLayer(mirrorLayer))) {
			if (collisionArray == null) {
				collisionArray = generateCollisionArray(origLayer, mirrorLayer);
			} else {
				if (origLayer.getOpacity() >= WorldConstants.GLOBAL_SOLID_OPACITY_THRESHOLD) {
					collisionArray = accumulateCollisionArray(collisionArray, origLayer, mirrorLayer);
				}
			}

			if (LevelEntityFactory.isInteractableLayer(origLayer)) {
				PlatformManipulationHandler handler = null;
				ArrayList<TerrainMapTileCoordinate> tileCoords = generatePlatformTileCoordinateArray(origLayer,
						mirrorLayer);

				InteractableLayerTypes layerType = LevelEntityFactory.getInteractableLayerType(origLayer);

				if (layerType.equals(InteractableLayerTypes.DX) || layerType.equals(InteractableLayerTypes.DY)) {
					handler = new MovingPlatformManipulationHandler(collisionArray, tileCoords,
							layerType.equals(InteractableLayerTypes.DX),
							layerType.equals(InteractableLayerTypes.DY));
				} else if (layerType.equals(InteractableLayerTypes.FADABLE)) {
					float opacity = origLayer.getOpacity();
					handler = new FadableLayerManipulationHandler(collisionArray, tileCoords,
							(opacity >= WorldConstants.GLOBAL_SOLID_OPACITY_THRESHOLD));
				}

				if (handler == null) {
					throw new GdxRuntimeException("Trying to create handler for invalid platform type.");
				} else {
					platformLayers.put(origLayer, handler);
					platformLayers.put(mirrorLayer, handler);
				}
			}
		}
	}

	retVal = new TerrainCollisionMap(egLayer, platformLayers, collisionArray);

	return retVal;
}
 
开发者ID:UoLCompSoc,项目名称:mobius,代码行数:68,代码来源:TerrainCollisionMap.java


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