當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。