use of com.badlogic.gdx.tests.utils.OrthoCamController in project libgdx by libgdx.
the class TideMapDirectLoaderTest 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.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
font = new BitmapFont();
batch = new SpriteBatch();
map = new TideMapLoader().load("data/maps/tide/Map01.tide");
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
use of com.badlogic.gdx.tests.utils.OrthoCamController in project libgdx by libgdx.
the class HexagonalTiledMapTest method create.
@Override
public void create() {
super.create();
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, (w / h) * 480, 480);
camera.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
hexture = new Texture(Gdx.files.internal("data/maps/tiled/hex/hexes.png"));
TextureRegion[][] hexes = TextureRegion.split(hexture, 112, 97);
map = new TiledMap();
MapLayers layers = map.getLayers();
TiledMapTile[] tiles = new TiledMapTile[3];
tiles[0] = new StaticTiledMapTile(new TextureRegion(hexes[0][0]));
tiles[1] = new StaticTiledMapTile(new TextureRegion(hexes[0][1]));
tiles[2] = new StaticTiledMapTile(new TextureRegion(hexes[1][0]));
for (int l = 0; l < 1; l++) {
TiledMapTileLayer layer = new TiledMapTileLayer(45, 30, 112, 97);
for (int y = 0; y < 30; y++) {
for (int x = 0; x < 45; x++) {
int id = (int) (Math.random() * 3);
Cell cell = new Cell();
cell.setTile(tiles[id]);
layer.setCell(x, y, cell);
}
}
layers.add(layer);
}
renderer = new HexagonalTiledMapRenderer(map);
}
use of com.badlogic.gdx.tests.utils.OrthoCamController in project libgdx by libgdx.
the class IsometricTileTest method create.
@Override
public void create() {
cam = new OrthographicCamera(480, 320);
camController = new OrthoCamController(cam);
Gdx.input.setInputProcessor(camController);
renderer = new ShapeRenderer();
texture = new Texture(Gdx.files.internal("data/isotile.png"));
Random rand = new Random();
for (int i = 0; i < LAYERS; i++) {
caches[i] = new SpriteCache();
SpriteCache cache = caches[i];
cache.beginCache();
int colX = HEIGHT * TILE_WIDTH / 2 - TILE_WIDTH / 2;
int colY = BOUND_Y - TILE_HEIGHT_DIAMOND;
for (int x = 0; x < WIDTH; x++) {
for (int y = 0; y < HEIGHT; y++) {
int tileX = colX - y * TILE_WIDTH / 2;
int tileY = colY - y * TILE_HEIGHT_DIAMOND / 2;
cache.add(texture, tileX, tileY, rand.nextInt(2) * 54, 0, TILE_WIDTH, TILE_HEIGHT);
}
colX += TILE_WIDTH / 2;
colY -= TILE_HEIGHT_DIAMOND / 2;
}
layers[i] = cache.endCache();
}
}
use of com.badlogic.gdx.tests.utils.OrthoCamController in project libgdx by libgdx.
the class SimpleStageCullingTest method create.
@Override
public void create() {
// create a stage and a camera controller so we can pan the view.
stage = new Stage();
;
// we know it's an ortho cam at this point!
camController = new OrthoCamController((OrthographicCamera) stage.getCamera());
Gdx.input.setInputProcessor(camController);
// load a dummy texture
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
// populate the stage with some actors and groups.
for (int i = 0; i < 5000; i++) {
Actor img = new CullableActor("img" + i, texture, (OrthographicCamera) stage.getCamera());
img.setX((float) Math.random() * 480 * 10);
img.setY((float) Math.random() * 320 * 10);
stage.addActor(img);
}
// we also want to output the number of visible actors, so we need a SpriteBatch and a BitmapFont
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
use of com.badlogic.gdx.tests.utils.OrthoCamController 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