use of com.badlogic.gdx.maps.tiled.TmxMapLoader in project libgdx by libgdx.
the class TiledMapLayerOffsetTest method create.
@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();
shapeRenderer = new ShapeRenderer();
assetManager = new AssetManager();
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
assetManager.load(MAP_ORTHO, TiledMap.class);
assetManager.load(MAP_ISO, TiledMap.class);
assetManager.load(MAP_ISO_STAG, TiledMap.class);
assetManager.load(MAP_HEX_X, TiledMap.class);
assetManager.load(MAP_HEX_Y, TiledMap.class);
assetManager.finishLoading();
map = assetManager.get(MAP_ORTHO);
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
use of com.badlogic.gdx.maps.tiled.TmxMapLoader in project libgdx by libgdx.
the class SuperKoalio method create.
@Override
public void create() {
// load the koala frames, split them, and assign them to Animations
koalaTexture = new Texture("data/maps/tiled/super-koalio/koalio.png");
TextureRegion[] regions = TextureRegion.split(koalaTexture, 18, 26)[0];
stand = new Animation(0, regions[0]);
jump = new Animation(0, regions[1]);
walk = new Animation(0.15f, regions[2], regions[3], regions[4]);
walk.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
// figure out the width and height of the koala for collision
// detection and rendering by converting a koala frames pixel
// size into world units (1 unit == 16 pixels)
Koala.WIDTH = 1 / 16f * regions[0].getRegionWidth();
Koala.HEIGHT = 1 / 16f * regions[0].getRegionHeight();
// load the map, set the unit scale to 1/16 (1 unit == 16 pixels)
map = new TmxMapLoader().load("data/maps/tiled/super-koalio/level1.tmx");
renderer = new OrthogonalTiledMapRenderer(map, 1 / 16f);
// create an orthographic camera, shows us 30x20 units of the world
camera = new OrthographicCamera();
camera.setToOrtho(false, 30, 20);
camera.update();
// create the Koala we want to move around the world
koala = new Koala();
koala.position.set(20, 20);
debugRenderer = new ShapeRenderer();
}
use of com.badlogic.gdx.maps.tiled.TmxMapLoader in project high-flyer by sangngh.
the class AbstractLevel method init.
protected void init() {
camera = new OrthographicCamera();
camera.setToOrtho(false, game.getSettings().getWindowWidth(), game.getSettings().getWindowHeight());
camera.update();
final String tiledMapPath = "data/screens/" + getLevelMap();
assetManager = new AssetManager();
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new ClasspathFileHandleResolver()));
assetManager.load(tiledMapPath, TiledMap.class);
assetManager.load(SPRITES, Texture.class);
assetManager.finishLoading();
TiledMap map = assetManager.get(tiledMapPath);
renderer = new OrthogonalTiledMapRenderer(map);
player = new Player(this.game, getSpriteTextures(), map.getLayers(), 480, 1045);
player.setPosition(0 * TILE_SIZE, 6 * TILE_SIZE);
player.rotate(90);
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/Amatic-Bold.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 40;
// parameter.characters = "Score: "+game.getState().getScore();
bitMapFontName = generator.generateFont(parameter);
generator.dispose();
}
use of com.badlogic.gdx.maps.tiled.TmxMapLoader in project var3dframe by Var3D.
the class VGame method getTiledMap.
/**
* tieldMap
*/
public TiledMap getTiledMap(String name) {
if (assets.isLoaded(name, TiledMap.class)) {
return assets.get(name, TiledMap.class);
} else {
assets.setLoader(TiledMap.class, new TmxMapLoader());
assets.load(name, TiledMap.class);
assets.finishLoading();
return assets.get(name, TiledMap.class);
}
}
use of com.badlogic.gdx.maps.tiled.TmxMapLoader in project libgdx by libgdx.
the class TiledMapAssetManagerTest method create.
@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);
String mapCustomValue = map.getProperties().get(MAP_PROPERTY_NAME, String.class);
Gdx.app.log("TiledMapAssetManagerTest", "Property : " + MAP_PROPERTY_NAME + ", Value : " + mapCustomValue);
if (!MAP_PROPERTY_VALUE.equals(mapCustomValue)) {
throw new RuntimeException("Failed to get map properties");
}
boolean boolCustomValue = map.getProperties().get(BOOL_PROPERTY_NAME, Boolean.class);
Gdx.app.log("TiledMapAssetManagerTest", "Property : " + BOOL_PROPERTY_NAME + ", Value : " + boolCustomValue);
if (boolCustomValue != BOOL_PROPERTY_VALUE) {
throw new RuntimeException("Failed to get boolean map properties");
}
int intCustomValue = map.getProperties().get(INT_PROPERTY_NAME, Integer.class);
Gdx.app.log("TiledMapAssetManagerTest", "Property : " + INT_PROPERTY_NAME + ", Value : " + intCustomValue);
if (intCustomValue != INT_PROPERTY_VALUE) {
throw new RuntimeException("Failed to get int map properties");
}
float floatCustomValue = map.getProperties().get(FLOAT_PROPERTY_NAME, Float.class);
Gdx.app.log("TiledMapAssetManagerTest", "Property : " + FLOAT_PROPERTY_NAME + ", Value : " + floatCustomValue);
if (floatCustomValue != FLOAT_PROPERTY_VALUE) {
throw new RuntimeException("Failed to get float map properties");
}
TiledMapTileSet tileset = map.getTileSets().getTileSet(0);
String tilesetCustomValue = tileset.getProperties().get(TILESET_PROPERTY_NAME, String.class);
if (!TILESET_PROPERTY_VALUE.equals(tilesetCustomValue)) {
throw new RuntimeException("Failed to get tileset properties");
}
TiledMapTile tile = tileset.getTile(1);
String tileCustomValue = tile.getProperties().get(TILE_PROPERTY_NAME, String.class);
if (!TILE_PROPERTY_VALUE.equals(tileCustomValue)) {
throw new RuntimeException("Failed to get tile properties");
}
MapLayer layer = map.getLayers().get(0);
String layerCustomValue = layer.getProperties().get(LAYER_PROPERTY_NAME, String.class);
if (!LAYER_PROPERTY_VALUE.equals(layerCustomValue)) {
throw new RuntimeException("Failed to get layer properties");
}
}
Aggregations