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