List of usage examples for com.badlogic.gdx.graphics.g2d.tiled TileAtlas TileAtlas
public TileAtlas(TiledMap map, FileHandle inputDir)
From source file:com.altportalgames.colorrain.utils.TiledMapHelper.java
License:Apache License
/** * Loads the requested tmx map file in to the object, sets up the camera and * controller.//from w w w . j a va 2 s . c om * * @param tmxFile */ public void loadMap() { final String path = "data/tramp/output/"; final String mapname = "tramp gzip"; FileHandle mapHandle = Gdx.files.internal(path + mapname + ".tmx"); FileHandle baseDir = Gdx.files.internal(path); //map = TiledLoader.createMap(Gdx.files.internal(tmxFile)); map = TiledLoader.createMap(mapHandle); int blockWidth = 10; int blockHeight = 15; tileAtlas = new TileAtlas(map, baseDir); tiledMapRenderer = new TileMapRenderer(map, tileAtlas, blockWidth, blockWidth); camera = new OrthographicCamera(320, 480); camera.position.set(map.width * map.tileWidth / 2, map.height * map.tileHeight / 2, 0); }
From source file:com.avechados.main.TiledMapHelper.java
License:Apache License
/** * Loads the requested tmx map file in to the helper. * /*w w w . j a v a 2 s. c om*/ * @param tmxFile */ public void loadMap(String tmxFile) { if (packFileDirectory == null) { throw new IllegalStateException("loadMap() called out of sequence"); } map = TiledLoader.createMap(Gdx.files.internal(tmxFile)); tileAtlas = new TileAtlas(map, packFileDirectory); tileMapRenderer = new TileMapRenderer(map, tileAtlas, 16, 16); }
From source file:com.car.utils.TiledMapHelper.java
License:Apache License
public TiledMapHelper(String tmxFile, String packDirectory) { racePositions = new HashMap<Integer, CarPosition>(); packFileDirectory = Gdx.files.internal(packDirectory); map = TiledLoader.createMap(Gdx.files.internal(tmxFile)); tileAtlas = new TileAtlas(map, packFileDirectory); loadMapProperties();//from w ww. j a v a 2 s .c o m parseMapObjects(); }
From source file:com.game.HelloWorld.java
License:Apache License
private void create_tiledMap() { final String path = "data/tiledmap/"; final String mapname = "foret"; FileHandle mapHandle = Gdx.files.internal(path + mapname + ".tmx"); FileHandle baseDir = Gdx.files.internal(path); this.mMap = TiledLoader.createMap(mapHandle); this.mAtlas = new TileAtlas(this.mMap, baseDir); int blockWidth = 128; int blockHeight = 128; mTileMapRenderer = new TileMapRenderer(this.mMap, this.mAtlas, blockWidth, blockHeight, 128, 128); for (TiledObjectGroup group : this.mMap.objectGroups) { for (TiledObject object : group.objects) { // TODO: Draw sprites where objects occur positionBoites.add(new Sphere(new Vector3(object.x, object.y, 0), 50)); System.out.println("Object " + object.name + " x,y = " + object.x + "," + object.y + " width,height = " + object.width + "," + object.height); }//from w ww .j a v a 2s . co m } // float aspectRatio = (float)Gdx.graphics.getWidth() / // (float)Gdx.graphics.getHeight(); // mCam = new OrthographicCamera(100f * aspectRatio, 100f); // mCam.position.set(mTileMapRenderer.getMapWidthUnits() / 2, // mTileMapRenderer.getMapHeightUnits() / 2, 0); // camController = new OrthoCamController(cam); // Gdx.input.setInputProcessor(camController); // mMaxCamPosition.set(mTileMapRenderer.getMapWidthUnits(), // mTileMapRenderer.getMapHeightUnits()); }
From source file:com.rabrant.bashnbump.TiledMapHelper.java
License:Apache License
/** * Loads the requested tmx map file in to the helper. * //from www . j a va 2 s . c o m * @param tmxFile */ public void loadMap(String tmxFile) { if (packFileDirectory == null) { throw new IllegalStateException("loadMap() called out of sequence"); } map = TiledLoader.createMap(Gdx.files.internal(tmxFile)); tileAtlas = new TileAtlas(map, packFileDirectory); tileMapRenderer = new TileMapRenderer(map, tileAtlas, 32, 16); }
From source file:com.raimsoft.dungeonball.tiled.TiledMapHelper2.java
License:Apache License
/** * tmx? . /* w w w . j ava 2s. c o m*/ * @param tmxFile */ public void loadMap(String tmxFile) { if (packFileHandle == null) throw new IllegalStateException("loadMap() called out of sequence"); map = TiledLoader.createMap(Gdx.files.internal(tmxFile)); tileAtlas = new TileAtlas(map, packFileHandle); tiledMapRenderer = new TileMapRenderer(map, tileAtlas, Gdx.graphics.getWidth() / 4, Gdx.graphics.getHeight() / 4); camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.position.set(0, 0, 0); }
From source file:com.ridiculousRPG.map.tiled.TiledMapWithEvents.java
License:Apache License
private TiledMap loadTileMap(String tmxPath) { this.tmxPath = tmxPath; final FileHandle tmxFile = Gdx.files.internal(tmxPath); final TiledMap map = TiledLoader.createMap(tmxFile); tileWidth = map.tileWidth;//from ww w.j a v a 2s . c o m tileHeight = map.tileHeight; width = map.width * tileWidth; height = map.height * tileHeight; new ExecWithGlContext() { @Override public void exec() { atlas = new TileAtlas(map, tmxFile.parent()); } }.runWait(); return map; }
From source file:de.philweb.bubblr.TiledMapHelper.java
License:Apache License
/** * Loads the requested tmx map file in to the helper. * // w w w . j a v a2 s . c o m * @param tmxFile */ public void loadMap(String tmxFile) { if (packFileDirectory == null) { throw new IllegalStateException("loadMap() called out of sequence"); } map = TiledLoader.createMap(Gdx.files.internal(tmxFile)); tileAtlas = new TileAtlas(map, packFileDirectory); // tileMapRenderer = new TileMapRenderer(map, tileAtlas, 16, 16); // wofr stehen 16, 16 : The tilesPerBlockX and tilesPerBlockY parameters will need to be adjusted for best performance. Smaller values will cull more precisely, but result in longer loading times. Larger values result in shorter loading times, but will cull less precisely. tileMapRenderer = new TileMapRenderer(map, tileAtlas, WorldRenderer.tiles_horizontally, WorldRenderer.tiles_vertically); }
From source file:net.k3rnel.unsealed.screens.BattleScreen.java
License:Open Source License
@Override public void show() { super.show(); long time = new Date().getTime(); Gdx.app.log(Unsealed.LOG, "Starting... "); if (!scriptedBattle) game.getMusicManager().play(UnsealedMusic.BATTLE); atlas = Unsealed.getInstance().getTextureAtlas(); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started atlas in... " + time); time = new Date().getTime(); // Load the tmx file into map tileMap = TiledLoader.createMap(Gdx.files.internal("map-atlases/" + mapname + ".tmx")); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started tiledMap in... " + time); time = new Date().getTime(); // Load the tiles into atlas tileAtlas = new TileAtlas(tileMap, Gdx.files.internal("map-atlases/")); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started tileAtlas in... " + time); time = new Date().getTime(); // Create the renderer tileMapRenderer = new TileMapRenderer(tileMap, tileAtlas, tileMap.width, tileMap.height); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started tileMapRenderer in... " + time); time = new Date().getTime(); // Create the camera camera = new OrthographicCamera(MENU_VIEWPORT_WIDTH, MENU_VIEWPORT_HEIGHT); camera.position.set(850, 1265, 0);/*from w w w . j ava2 s . c om*/ camera.zoom = 0.8f; camera.update(); AtlasRegion atlasRegion = atlas.findRegion("battle/ui/field-3x3"); battleoverlay = new Image(atlasRegion); battleoverlay.setScale(1.2f); battleoverlay.setX(MENU_VIEWPORT_WIDTH / 2 - (battleoverlay.getWidth() * battleoverlay.getScaleX()) / 2); battleoverlay.setY(MENU_VIEWPORT_HEIGHT / 2 - (battleoverlay.getHeight() * battleoverlay.getScaleY()) - 65); stage.addActor(battleoverlay); stateTime = 0; characters = new ArrayList<MapCharacter>(); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started camera & overlay in... " + time); time = new Date().getTime(); hud = new BattleHUD(getAtlas(), this.stage.getWidth(), stage.getHeight()); hud.xButton.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { super.touchDown(event, x, y, pointer, button); buttonPress(6, true); Gdx.input.vibrate(10); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); buttonPress(6, false); } }); hud.bButton.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { super.touchDown(event, x, y, pointer, button); buttonPress(7, true); Gdx.input.vibrate(10); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); buttonPress(7, false); } }); hud.aButton.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { super.touchDown(event, x, y, pointer, button); buttonPress(8, true); Gdx.input.vibrate(10); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); buttonPress(8, false); } }); hud.yButton.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { super.touchDown(event, x, y, pointer, button); buttonPress(9, true); Gdx.input.vibrate(10); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); buttonPress(9, false); } }); if (Gdx.app.getType() == ApplicationType.Android || Unsealed.DEBUG == true) { hud.leftTrigger.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { super.touchDown(event, x, y, pointer, button); buttonPress(4, true); Gdx.input.vibrate(10); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); buttonPress(4, false); } }); hud.rightTrigger.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { super.touchDown(event, x, y, pointer, button); buttonPress(5, true); Gdx.input.vibrate(10); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); buttonPress(5, false); } }); } time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started HUD in... " + time); time = new Date().getTime(); grid = new BattleGrid(getAtlas(), this.stage.getWidth(), stage.getHeight(), 6, 3); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started GRID in... " + time); time = new Date().getTime(); hero = new Lidia(getAtlas(), 150, 1, 1); hero.setGrid(1, 1); hero.setSkill1(new EarthSpikes(getAtlas())); hud.xButton.addActor(hero.getSkill1()); hero.setSkill2(new TornadoVacuum(getAtlas())); hud.bButton.addActor(hero.getSkill2()); hero.setSkill3(new FireLion(getAtlas())); hud.aButton.addActor(hero.getSkill3()); grid.assignEntity(hero); hero.setSkill4(new ThunderClaw(getAtlas())); hero.setSkill5(new IceTentacle(getAtlas())); hero.setSkill6(new FirePunch(getAtlas())); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started hero in... " + time); time = new Date().getTime(); if (!scriptedBattle) grid.spawnEnemies(bonus); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started spawn enemies in... " + time); time = new Date().getTime(); roundLabel = new Label("Round " + round, getSkin()); roundLabel.setX(350); roundLabel.setY(350); // this.stage.addActor(roundLabel); atlasRegion = atlas.findRegion("battle/ui/continue"); restartButton = new ImageButton(new TextureRegionDrawable(atlasRegion), new TextureRegionDrawable(atlasRegion)); restartButton.setY(140); restartButton.setX(170); restartButton.setWidth(426); restartButton.setHeight(165); restartButton.setVisible(false); restartButton.setDisabled(true); restartButton.addListener(new ClickListener() { @Override public void clicked(InputEvent arg0, float arg1, float arg2) { hero = new Lidia(getAtlas(), 150, 1, 1); hero.setGrid(1, 1); hero.reset(); hero.setSkill1(new EarthSpikes(getAtlas())); hero.setSkill2(new TornadoVacuum(getAtlas())); hero.setSkill3(new FireLion(getAtlas())); grid.reset(); grid.assignEntity(hero); bonus = 1; round = 1; restartButton.setVisible(false); restartButton.setDisabled(true); grid.spawnEnemies(bonus); } }); this.stage.addActor(restartButton); NinePatch patch = getAtlas().createPatch("maps/dialog-box"); textBoxStyle = new StyledTable.TableStyle(); textBoxStyle.background = new NinePatchDrawable(patch); textBoxStyle.font = new BitmapFont(); textBoxStyle.padX = 8; textBoxStyle.padY = 4; dialog = new TextBox("", textBoxStyle); dialog.setWidth(Gdx.graphics.getWidth()); dialog.setHeight(Gdx.graphics.getHeight() / 8); dialog.setVisible(false); time = new Date().getTime() - time; Gdx.app.log(Unsealed.LOG, "Started the rest in... " + time); time = new Date().getTime(); hud.addActor(dialog); Gdx.input.setInputProcessor(new InputMultiplexer(this, stage, hud, new SimpleDirectionGestureDetector(new SimpleDirectionGestureDetector.UnsealedDirectionListener() { @Override public void onUpLeft() { buttonPress(0, true); } @Override public void onRightLeft() { buttonPress(3, true); } @Override public void onLeftLeft() { buttonPress(2, true); } @Override public void onDownLeft() { buttonPress(1, true); } @Override public void onDownRight() { buttonPress(7, true); buttonPress(7, false); } @Override public void onLeftRight() { buttonPress(6, true); buttonPress(6, false); } @Override public void onRightRight() { buttonPress(8, true); buttonPress(8, false); } @Override public void onUpRight() { buttonPress(9, true); buttonPress(9, false); } @Override public void onTapLeft() { buttonPress(4, true); buttonPress(4, false); } @Override public void onTapRight() { buttonPress(5, true); buttonPress(5, false); } }))); }
From source file:net.k3rnel.unsealed.story.AbstractChapter.java
License:Open Source License
public void show() { super.show(); act = 0;/*from w w w . j a v a2 s . c o m*/ // Load the tmx file into map tileMap = TiledLoader.createMap(Gdx.files.internal("map-atlases/" + mapname + ".tmx")); // Load the tiles into atlas tileAtlas = new TileAtlas(tileMap, Gdx.files.internal("map-atlases/")); // Create the renderer tileMapRenderer = new TileMapRenderer(tileMap, tileAtlas, tileMap.width, tileMap.height); // Create the camera camera = new OrthographicCamera(MENU_VIEWPORT_WIDTH, MENU_VIEWPORT_HEIGHT); camera.position.set(this.stage.getWidth() / 2, this.stage.getHeight() / 2, 0); NinePatch patch = getAtlas().createPatch("maps/dialog-box"); textBoxStyle = new StyledTable.TableStyle(); textBoxStyle.background = new NinePatchDrawable(patch); textBoxStyle.font = new BitmapFont(); textBoxStyle.padX = 8; textBoxStyle.padY = 4; characters = new ArrayList<MapCharacter>(); stage.setCamera(camera); dialog = new TextBox("", textBoxStyle); dialog.setWidth(Gdx.graphics.getWidth()); dialog.setHeight(Gdx.graphics.getHeight() / 4); dialog.setVisible(false); hud.addActor(dialog); Gdx.input.setInputProcessor(new InputMultiplexer(this, hud)); }