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


Java MapLayers类代码示例

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


MapLayers类属于com.badlogic.gdx.maps包,在下文中一共展示了MapLayers类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: genVoidMap

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
public static TiledMap genVoidMap(int w, int h) {
    ImpassableCells.clear();
    tileAtlas = ResKeeper.get(AtlasId.MAP_TILES);
    TiledMap map = new TiledMap();
    MapLayers layers = map.getLayers();
    TiledMapTileLayer layerBg = new TiledMapTileLayer(w, h, CELL_SIZE,
            CELL_SIZE);
    MapCell cell = getCell(TileCode.GRASS, true);
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            layerBg.setCell(i, j, cell);
        }
    }
    layers.add(layerBg);
    cells.clear();

    return map;
}
 
开发者ID:NaikSoftware,项目名称:SaveUA,代码行数:19,代码来源:MapUtils.java

示例3: generateInvertedMap

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
public static TiledMap generateInvertedMap(TiledMap map) {
	TiledMap invertedMap = new TiledMap();

	MapLayers invertedLayers = invertedMap.getLayers();

	for (int i = 0; i < map.getLayers().getCount(); i++) {
		TiledMapTileLayer origLayer = (TiledMapTileLayer) map.getLayers().get(i);

		TiledMapTileLayer tempLayer = invertLayer(origLayer);

		tempLayer.setOpacity(origLayer.getOpacity());
		tempLayer.setName(origLayer.getName());
		tempLayer.setVisible(origLayer.isVisible());
		copyLayerProperties(origLayer, tempLayer);

		invertedLayers.add(tempLayer);
	}

	return invertedMap;
}
 
开发者ID:UoLCompSoc,项目名称:mobius,代码行数:21,代码来源:LevelEntityFactory.java

示例4: MockTiledMapBuilder

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
public MockTiledMapBuilder(int xTiles, int yTiles, int tileSize) {
   map = mock(TiledMap.class);
   layers = new MapLayers();
   MapProperties properties = new MapProperties();
   properties.put(Constants.WIDTH, xTiles);
   properties.put(Constants.HEIGHT, yTiles);
   when(map.getProperties()).thenReturn(properties);
   this.size = tileSize;
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:10,代码来源:MockTiledMapBuilder.java

示例5: 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

示例6: create

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
@Override
public void create () {
	super.create();
	float w = Gdx.graphics.getWidth();
	float h = Gdx.graphics.getHeight();

	camera = new OrthographicCamera();
	camera.setToOrtho(false, (w / h) * 480, 480);
	camera.update();

	cameraController = new OrthoCamController(camera);
	Gdx.input.setInputProcessor(cameraController);

	hexture = new Texture(Gdx.files.internal("data/maps/tiled/hex/hexes.png"));
	TextureRegion[][] hexes = TextureRegion.split(hexture, 112, 97);
	map = new TiledMap();
	MapLayers layers = map.getLayers();
	TiledMapTile[] tiles = new TiledMapTile[3];
	tiles[0] = new StaticTiledMapTile(new TextureRegion(hexes[0][0]));
	tiles[1] = new StaticTiledMapTile(new TextureRegion(hexes[0][1]));
	tiles[2] = new StaticTiledMapTile(new TextureRegion(hexes[1][0]));

	for (int l = 0; l < 1; l++) {
		TiledMapTileLayer layer = new TiledMapTileLayer(45, 30, 112, 97);
		for (int y = 0; y < 30; y++) {
			for (int x = 0; x < 45; x++) {
				int id = (int)(Math.random() * 3);
				Cell cell = new Cell();
				cell.setTile(tiles[id]);
				layer.setCell(x, y, cell);
			}
		}
		layers.add(layer);
	}

	renderer = new HexagonalTiledMapRenderer(map);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:38,代码来源:HexagonalTiledMapTest.java

示例7: create

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
@Override
public void create () {
	float w = Gdx.graphics.getWidth();
	float h = Gdx.graphics.getHeight();

	camera = new OrthographicCamera();
	camera.setToOrtho(false, (w / h) * 320, 320);
	camera.update();

	cameraController = new OrthoCamController(camera);
	Gdx.input.setInputProcessor(cameraController);

	font = new BitmapFont();
	batch = new SpriteBatch();

	{
		tiles = new Texture(Gdx.files.internal("data/maps/tiled/tiles.png"));
		TextureRegion[][] splitTiles = TextureRegion.split(tiles, 32, 32);
		map = new TiledMap();
		MapLayers layers = map.getLayers();
		for (int l = 0; l < 20; l++) {
			TiledMapTileLayer layer = new TiledMapTileLayer(150, 100, 32, 32);
			for (int x = 0; x < 150; x++) {
				for (int y = 0; y < 100; y++) {
					int ty = (int)(Math.random() * splitTiles.length);
					int tx = (int)(Math.random() * splitTiles[ty].length);
					Cell cell = new Cell();
					cell.setTile(new StaticTiledMapTile(splitTiles[ty][tx]));
					layer.setCell(x, y, cell);
				}
			}
			layers.add(layer);
		}
	}

	renderer = new OrthogonalTiledMapRenderer(map);

}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:39,代码来源:TiledMapBench.java

示例8: getLayers

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
public MapLayers getLayers() {
 return _tileMap.getLayers();
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:4,代码来源:TMXTiledMap.java

示例9: Box2DWorldCreator

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
/**
 * Sets up the collision boxes of the map objects
 */
public Box2DWorldCreator(PlayScreen screen) {
    this.playScreen = screen;

    TiledMap map = screen.getMap();
    MapLayers mapLayers = map.getLayers();

    // Loop through every layer in the map
    for (MapLayer mapLayer : mapLayers) {
        // Loop through every rectangular shape in this layer
        for (MapObject mapObject : mapLayer.getObjects().getByType(RectangleMapObject.class)) {

            // The rectangular collision box
            Rectangle rectangle = ((RectangleMapObject) mapObject).getRectangle();

            // Create object depending on the type of the shape
            switch (mapLayer.getName()) {
                case "background":
                    // Only graphics
                    break;
                case "graphics":
                    // Only graphics
                    break;
                case "ground":
                    groundObjects.add(new Ground(screen, rectangle));
                    break;
                case "death":
                    deathTileObjects.add(new DeathTile(screen, rectangle));
                    break;
                case "weapon":
                    weaponPickupObjects.add(new WeaponPickup(screen, rectangle));
                    break;
                case "finish":
                    finishObjects.add(new Finish(screen, rectangle));
                    break;
                case "jumpable":
                    jumpableObjects.add(new Jumpable(screen, rectangle));
                    break;
                case "enemy_move_border":
                    enemyMoveBorderObjects.add(new EnemyMoveBorder(screen, rectangle));
                    break;
                case "enemies":
                    addEnemy(mapObject, ((RectangleMapObject) mapObject).getRectangle());
                    break;
                default:
                    break;
            }
        }
    }
}
 
开发者ID:johannesmols,项目名称:GangsterSquirrel,代码行数:53,代码来源:Box2DWorldCreator.java

示例10: 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

示例11: getMapLayers

import com.badlogic.gdx.maps.MapLayers; //导入依赖的package包/类
public MapLayers getMapLayers(){
	return mlayers;
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:4,代码来源:Map.java


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