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


Java TmxMapLoader类代码示例

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


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

示例1: TiledMapLevelLoadable

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public TiledMapLevelLoadable(int levelId) {
    this.id = levelId;

    respawnPosition = new Vector2();
    freeBodyDefinitions = new Array<FixtureBodyDefinition>();
    entityDefinitions = new Array<EntityDefinition>();
    scriptDefinitions = new Array<ScriptDefinition>();
    canvasMap = new LinkedHashMap<IRender, Integer>();
    bodySkeletonMap = new HashMap<String, MapObject>();

    String tileMapName = Globals.getLevelTileMapName(levelId);
    filename = AssetManager.getFilePath("levels", tileMapName + ".tmx");
    TmxMapLoader.Parameters params = new TmxMapLoader.Parameters();
    params.flipY = false;

    tiledMap = new TmxMapLoader().load(filename, params);

    background = new ParallaxBackground();
    setBackground();

    processLayers();
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:23,代码来源:TiledMapLevelLoadable.java

示例2: loadTiledMap

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public void loadTiledMap(String mapName){
	logger.debug("Loading TiledMap: " + mapName);
	
	this.clear();
	
	try{
		map = new TmxMapLoader().load(mapName);
	}
	catch(Exception e){
		logger.error("Map load failed .. " + e.getMessage());
		return;
	}
	mapRenderer = new OrthogonalTiledMapRenderer(map,batch);
	
	createPhysics(map);
       createEntities(map);
       createSpawnZones(map);
       createDropOffPoints(map);
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:20,代码来源:Level.java

示例3: onEnter

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

	camera = new OrthographicCamera();
	camera.setToOrtho(false, (w / h) * 640, 640);
	camera.update();
	
	map = new TmxMapLoader().load("Resource/tiles.tmx");
	renderer = new OrthogonalTiledMapRenderer(map, 2f);//1f / 32f);
	
	func = CC.Scheduler().renderAfterSchedulePerFrame((t)->{
		camera.position.set(500, 320, 0);
		camera.update();
		renderer.setView(
				camera.combined,
				0, 0, 1000, 500);
		renderer.render();
		return false;
	}, 0, false);
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:24,代码来源:TiledMapTests.java

示例4: loadMap

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
/**
 * Lädt die Map aus der Datei in den Speicher.
 *
 * Wird von {@link #initMap()} aufgerufen.
 */
private void loadMap()
{
    FileHandle mapFile = Gdx.files.internal("data/maps/" + mapName + ".tmx");

    if (!mapFile.exists() || mapFile.isDirectory())
    {
        Gdx.app.error("ERROR", "The map file " + mapName + ".tmx doesn't exists!");
        levelManager.exitToMenu();
        return;
    }

    TmxMapLoader.Parameters mapLoaderParameters = new TmxMapLoader.Parameters();
    mapLoaderParameters.textureMagFilter = Texture.TextureFilter.Nearest;
    mapLoaderParameters.textureMinFilter = Texture.TextureFilter.Nearest;

    tileMap = new TmxMapLoader().load(mapFile.path(), mapLoaderParameters);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:23,代码来源:Level.java

示例5: init

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public static void init() {

        assetManager.setLoader(TiledMap.class, new TmxMapLoader());

        for (Assets.Fonts font : Assets.Fonts.values()) {
            assetManager.load(font.getPath(), BitmapFont.class);
        }
        for (Assets.Textures texture : Assets.Textures.values()) {
            assetManager.load(texture.getPath(), Texture.class);
        }
        for (Assets.Maps map : Assets.Maps.values()) {
            assetManager.load(map.getPath(), TiledMap.class);
        }
        for (Assets.Musics music : Assets.Musics.values()) {
            assetManager.load(music.getPath(), Music.class);
        }
        for (Assets.Sounds sound : Assets.Sounds.values()) {
            assetManager.load(sound.getPath(), Sound.class);
        }
        assetManager.finishLoading();
    }
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:22,代码来源:AssetManager.java

示例6: MapLoader

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public MapLoader(OrthographicCamera camera, SendCommand sendCommand)
{
    this.camera = camera;
    this.tiledMap = new TmxMapLoader().load(Constants.TESTMAPPATH);
    this.tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
    this.blockLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Blocks");
    this.floorLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Floor");
    this.bombLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Bombs");
    this.itemLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Items");
    this.sendCommand = sendCommand;
    
    Constants.MAPTEXTUREWIDTH = blockLayer.getTileWidth();
    Constants.MAPTEXTUREHEIGHT = blockLayer.getTileWidth();
    
    findAllItemFields();
}
 
开发者ID:Aeo-Informatik,项目名称:Space-Bombs,代码行数:17,代码来源:MapLoader.java

示例7: setNewMap

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
/**-------------------Getter & Setter-------------------**/
public void setNewMap(String path)
{
    this.tiledMap = new TmxMapLoader().load(path);
    this.tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
    
    this.blockLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Blocks");
    this.floorLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Floor");
    this.bombLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Bombs");
    this.itemLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Items");

    Constants.MAPTEXTUREWIDTH = blockLayer.getTileWidth();
    Constants.MAPTEXTUREHEIGHT = blockLayer.getTileWidth();
    
    findAllItemFields();
}
 
开发者ID:Aeo-Informatik,项目名称:Space-Bombs,代码行数:17,代码来源:MapLoader.java

示例8: TmxMap

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public TmxMap(String levelName) {
	
	map = new TmxMapLoader().load(levelName);
	tileLayer = (TiledMapTileLayer) map.getLayers().get(0);
	objectsLayer = map.getLayers().get(1);
	MapProperties properties = tileLayer.getProperties();				
	worldType = WorldTypeEnum.valueOf(((String)properties.get(TilemapPropertiesConstants.WORLD)).toUpperCase());
	musicTheme = ((String)properties.get("music")).toUpperCase();
	String sScrollableTo = (String)properties.get("scrollableTo");
	scrollMaxValue = sScrollableTo!=null && !sScrollableTo.equals("") ? Float.parseFloat(sScrollableTo) : 1000;
	String sCastle = (String)properties.get("castle");
	endLevelCastleType = worldType !=WorldTypeEnum.CASTLE ? sCastle!=null && !sCastle.equals("") ? CastleTypeEnum.valueOf(sCastle.toUpperCase()) : CastleTypeEnum.SMALL : null;		
		initBlocks(worldType);		
	initMapObjects();		
	initBackgrounds(properties);
}
 
开发者ID:provenza24,项目名称:Mario-Libgdx,代码行数:17,代码来源:TmxMap.java

示例9: CoffeeLevel

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public CoffeeLevel(String mapPath) {
    this.map = new TmxMapLoader().load(mapPath);

    //configuration des variables de tailles
    this.tileWidth = ((Integer) this.map.getProperties().get("tilewidth"));
    this.tileHeight = ((Integer) this.map.getProperties().get("tileheight"));

    mapWidthTiled = (Integer) this.map.getProperties().get("width");
    mapHeightTiled = (Integer) this.map.getProperties().get("height");

    this.mapWidthPixel = mapWidthTiled * tileWidth;
    this.mapHeightPixel = mapHeightTiled * tileHeight;

    vannes = new HashSet<Vanne>();
    indicateurs = new HashSet<KoffeeMeter>();

    this.canalisation = new Canalisation(map,mapWidthTiled,mapHeightTiled);
}
 
开发者ID:naomiHauret,项目名称:OdysseeDesMaths,代码行数:19,代码来源:CoffeeLevel.java

示例10: GameScreen

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
/**
 * 
 */
public GameScreen(SupaBox game) {
	this.game = game;
	
	//float aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth();
	
	camera = new OrthographicCamera();
	viewport = new FitViewport(24, 16, camera);
	viewport.apply();
	
	camera.position.set(viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2, 0);
	
	debugRenderer = new Box2DDebugRenderer();
	world = new World(new Vector2(0, -9.8f), true);
	
	mapLoader = new TmxMapLoader();
	map = mapLoader.load("crate.tmx");
	mapRenderer = new OrthogonalTiledMapRenderer(map, 1f / SupaBox.PPM);
	
	bodyBuilder = new BodyBuilder();
	bodyBuilder.createBodies(entities, world, map);
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:25,代码来源:GameScreen.java

示例11: create

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

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

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

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

	map = new TmxMapLoader().load("data/maps/tiled/super-koalio/level1.tmx");
	renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:19,代码来源:TiledMapDirectLoaderTest.java

示例12: create

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

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

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

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

	assetManager = new AssetManager();
	assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
	assetManager.load("data/maps/tiled/isometric_grass_and_water.tmx", TiledMap.class);
	assetManager.finishLoading();
	map = assetManager.get("data/maps/tiled/isometric_grass_and_water.tmx");
	renderer = new IsometricTiledMapRenderer(map, 1f / 64f);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:24,代码来源:TiledMapAssetManagerTest.java

示例13: loadMap

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public static void loadMap(String fileName) {
	TiledMap map = new TmxMapLoader().load(fileName);
	for (int i = 0; i < map.getLayers().getCount(); i++) {
		TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers()
				.get(i);
		for (int x = 0; x < layer.getWidth(); x++) {
			for (int y = 0; y < layer.getHeight(); y++) {
				Cell cell = layer.getCell(x, layer.getHeight() - 1 - y);
				if (cell == null) {
					continue;
				}
				Entity e = EntityManager.createTile((String) cell.getTile()
						.getProperties().get("name"), x * 16, y * 16);
				EntityManager.setEntityLayer(e, Name.LAYER_FLOOR);
			}
		}
	}
}
 
开发者ID:Teascade,项目名称:Shadow-of-Goritur,代码行数:19,代码来源:MapLoader.java

示例14: SpriteManager

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
public SpriteManager(Robin2DX game) {
	this.game = game;

	// Inicia la cámara para jugar
	camera = new OrthographicCamera();
	// La cámara mostrará 30 celdas de ancho por 30 celdas de alto
	camera.setToOrtho(false, 30, 30);
	camera.zoom = 1 / 2f;
	camera.update();
	
	// Carga el mapa y obtiene la capa de colisión (objetos con los que el personaje puede chocar)
	map = new TmxMapLoader().load("levels/tiledmap1.tmx");
	collisionLayer = (TiledMapTileLayer) map.getLayers().get("base");
	
	// Crea el renderizador del tiledmap
	mapRenderer = new OrthogonalTiledMapRenderer(map);
	// Hay que utilizar el spritebatch del mapa para pintar el nivel.
	// En caso contrario no ubica ni escala bien al personaje en el mapa
	batch = mapRenderer.getSpriteBatch();
	
	// Posiciona al jugador en el mapa
	player = new Player(15 * Constants.TILE_WIDTH, 10 * Constants.TILE_HEIGHT);
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:24,代码来源:SpriteManager.java

示例15: loadNonBlocking

import com.badlogic.gdx.maps.tiled.TmxMapLoader; //导入依赖的package包/类
private static boolean loadNonBlocking(){
	if(!readinglock){
		clear();
		loadAssets();
		readinglock = true;
	}
	// once update returns true then condition is satisfied and the lock stops update call
	if(!updatinglock)
		if(assetMan.update()){
			assetMan.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
			getAssets();
			updatinglock = true;
			if(Scene.splashDuration != 0)
				Scene.nextSceneWithDelay(Scene.splashDuration);
			else
				Scene.nextScene();
		}
	return updatinglock;
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:20,代码来源:Asset.java


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