本文整理汇总了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);
}
示例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());
}
}
示例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;
}