本文整理匯總了Java中com.badlogic.gdx.maps.tiled.TmxMapLoader.load方法的典型用法代碼示例。如果您正苦於以下問題:Java TmxMapLoader.load方法的具體用法?Java TmxMapLoader.load怎麽用?Java TmxMapLoader.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.maps.tiled.TmxMapLoader
的用法示例。
在下文中一共展示了TmxMapLoader.load方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: initWithTMXFile
import com.badlogic.gdx.maps.tiled.TmxMapLoader; //導入方法依賴的package包/類
/** initializes a TMX Tiled Map with a TMX file */
public boolean initWithTMXFile(String tmxFile) {
if(_tileMap != null) {
_tileMap.dispose();
}
TmxMapLoader newLoader = new TmxMapLoader() {
public FileHandle resolve(String fileName) {
return CC.File(fileName);
}
};
_tileMap = newLoader.load(tmxFile);
_initProperties();
_tileMapRender = new OrthogonalTiledMapRenderer(_tileMap, 1f);
return true;
}
示例3: PlayScreen
import com.badlogic.gdx.maps.tiled.TmxMapLoader; //導入方法依賴的package包/類
public PlayScreen(NoObjectionGame game) {
atlas = new TextureAtlas("dudestuff3.pack");
this.game = game;
bg = new Texture("main_background.png");
gameCam = new OrthographicCamera();
gamePort = new FitViewport(NoObjectionGame.V_WIDTH / NoObjectionGame.PPM, NoObjectionGame.V_HEIGHT / NoObjectionGame.PPM, gameCam);
hud = new Hud(game.batch);
maploader = new TmxMapLoader();
map = maploader.load("map1.tmx");
renderer = new OrthoCachedTiledMapRenderer(map, 1 / NoObjectionGame.PPM);
gameCam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2, 0);
world = new World(new Vector2(0, -10), true);
b2dr = new Box2DDebugRenderer();
new B2WorldCreator(world, map);
hero = new Hero(world, this);
controller = new Controller();
worldContactListener = new WorldContactListener();
world.setContactListener(worldContactListener);
//timer
sb = new SpriteBatch();
viewport = new FitViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
stage = new Stage(viewport, sb);
table = new Table();
table.top();
table.setFillParent(true);
countDownLabel = new Label(Float.toString(playTime), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
table.add(countDownLabel).expandX();
stage.addActor(table);
}
示例4: PlayScreen
import com.badlogic.gdx.maps.tiled.TmxMapLoader; //導入方法依賴的package包/類
public PlayScreen(QuackHack game) {
this.game = game;
gamecam = new OrthographicCamera();
gamePort = new ExtendViewport(QuackHack.V_WIDTH * 4 / QuackHack.PPM, QuackHack.V_HEIGHT * 4 / QuackHack.PPM, gamecam);
hud = new Hud(game);
maploader = new TmxMapLoader();
map = maploader.load("Tunnelv0.tmx");
renderer = new OrthogonalTiledMapRenderer(map, 1 / QuackHack.PPM);
gameMusic = Gdx.audio.newMusic(Gdx.files.internal("Airborn.wav"));
gameMusic.setLooping(true);
gameMusic.play();
gamecam.position.set(gamePort.getMinWorldWidth() / 2, gamePort.getMinWorldHeight() / 2, 0);
world = new World(new Vector2(0, -100), true);
//b2dr = new Box2DDebugRenderer();
new B2WorldCreator(world, map, this);
world.setContactListener(new WorldContactListener());
game.getServer().registerNetListener(this);
rayHandler = rayHandlerGenerator();
for(Connection c: game.getServer().getPlayers()) {
System.out.println("New Player! id: "+game.getServer().getPlayerType(c.getID()).toString());
players.put(c.getID(), new Player(c.getID(), world, this, game.getServer().getPlayerType(c.getID())));
}
game.getServer().sendCommand(NetCommand.PLAYER_JOIN);
//http://www.badlogicgames.com/forum/viewtopic.php?f=17&t=1795
rbg = new ParallaxBackground(new ParallaxLayer[]{
new ParallaxLayer(new TextureRegion(new Texture(Gdx.files.internal("blue_grass.png"))),new Vector2(0.5f, 0.5f),new Vector2(0, 300)),
//new ParallaxLayer(atlas.findRegion("bg2"),new Vector2(1.0f,1.0f),new Vector2(0, 500)),
}, 800, 480,new Vector2(150,0));
}
示例5: PlayScreen
import com.badlogic.gdx.maps.tiled.TmxMapLoader; //導入方法依賴的package包/類
public PlayScreen(MarioBros game) {
this.game = game;
gameCam = new OrthographicCamera();
gamePort = new FitViewport(MarioBros.V_WIDTH / MarioBros.PPM, MarioBros.V_HEIGHT / MarioBros.PPM, gameCam);
hud = new Hud(game.batch);
mapLoader = new TmxMapLoader();
map = mapLoader.load("level1.tmx");
atlas = new TextureAtlas("Mario_and_Enemies.pack");
renderer = new OrthogonalTiledMapRenderer(map, 1 / MarioBros.PPM);
//set gamecam to the center at the start of the game
gameCam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2, 0);
world = new World(new Vector2(0, -10), true);
b2dr = new Box2DDebugRenderer();
creator = new B2WorldCreator(this);
player = new Mario(this);
world.setContactListener(new WorldContactListener());
music = MarioBros.manager.get("audio/music/mario_music.ogg", Music.class);
music.setLooping(true);
music.play();
items = new Array<Item>();
itemsToSpawn = new LinkedBlockingQueue<ItemDef>();
}
示例6: Ground
import com.badlogic.gdx.maps.tiled.TmxMapLoader; //導入方法依賴的package包/類
public Ground() {
mapLoader = new TmxMapLoader();
map = mapLoader.load("map_1.tmx");
}