Java 类com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer 实例源码

项目:cocos2d-java    文件:TiledMapTests.java   
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);
}
项目:feup-lpoo-armadillo    文件:GameScreen.java   
/**
 * Game Screen's constructor.
 * The Game Screen's is responsible for drawing the current game.
 *
 * @param game         The current game session.
 * @param currentLevel The game's level that the game screen will draw.
 */
public GameScreen(Armadillo game, int currentLevel) {
    this.game = game;

    model = new GameModel();
    this.currentLevel = currentLevel;
    loadNextMap();

    camera = createCamera();
    controller = new GameInputPoller(model);
    mapRenderer = new OrthogonalTiledMapRenderer(model.getMap(), game.getBatch());

    hud = new HudMenu(game, model);
    hud.getInputMultiplexer().addProcessor(new GameInputHandler(model));
    gameBackground = game.getAssetManager().get("background.png", Texture.class);
}
项目:MMORPG_Prototype    文件:PlayState.java   
public PlayState(Server server, StateManager states)
{
    this.server = server;
    this.states = states;
    rewardForFisnishedQuestObserver = new RewardForFinishedQuestObserver(this, this);
    questEventsHandler = new EventsHandler(rewardForFisnishedQuestObserver);
    camera.setToOrtho(false);
    camera.viewportWidth = 3000;
    camera.viewportHeight = 1600;

    collisionMap.setScale(1);
    TiledMap map = loadMap();

    if (ServerSettings.isHeadless)
        mapRenderer = new NullOrthogonalTiledMapRenderer();
    else
        mapRenderer = new OrthogonalTiledMapRenderer(map, Assets.getBatch());

    Gdx.input.setInputProcessor(inputHandler);

    addNpcs();
    addGameObject(ObjectsIdentifiers.QUEST_BOARD, 100, 100);
}
项目:ExamensArbeteTD    文件:PlayState.java   
public PlayState(GameStateManager gsm) {
    super(gsm);
    Assets.loadGameStageAssets();
    Engine ashleyEngine = new Engine();
    LevelManager.loadLevel("maps/simple-map.tmx");
    _renderer = new OrthogonalTiledMapRenderer(LevelManager.tiledMap);
    _gameCamera = new OrthographicCamera();
    EntityFactory entityFactory = new EntityFactory(ashleyEngine);
    InputHandler inputhandler = new InputHandler(_gameCamera,entityFactory,gsm,ashleyEngine);
    _uiStage = new UiStage();
    _entityManager = new EntityManager(ashleyEngine, _batch, _gameCamera, inputhandler, _uiStage, gsm, entityFactory);

    InputMultiplexer multi = new InputMultiplexer();

    multi.addProcessor(_uiStage);
    multi.addProcessor(inputhandler);
    Gdx.input.setInputProcessor(multi);
}
项目:Dungeon    文件:Main.java   
@Override
public void create () {
    float w = Gdx.graphics.getWidth  ();
    float h = Gdx.graphics.getHeight ();

    hud              = new Hud                        ();
    batch            = new SpriteBatch                ();
    hudBatch         = new SpriteBatch                ();
    hudRend          = new ShapeRenderer              ();
    shaper           = new ShapeRenderer              ();

    level1           = new LevelWithSpawns            ("dungeon_1.tmx", new Vector2(14,  7));
    level2           = new LevelWithSpawns            ("dungeon_2.tmx", new Vector2(18, 10));

    currentLevel     = level2;

    player           = new Player                     (new Texture("player_mage.png"), (int)currentLevel.spawn.x, (int)currentLevel.spawn.y);
    tiledMapRenderer = new OrthogonalTiledMapRenderer (level2.getLevel());
    camera           = new OrthographicCamera         ();

    camera.position.x  = player.x;
    camera.position.y  = player.y;
    camera.zoom        = 0.1f;
    camera.setToOrtho  (false,w,h);
    camera.update      ();
}
项目:Space-Bombs    文件:MapLoader.java   
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();
}
项目:Space-Bombs    文件:MapLoader.java   
/**-------------------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();
}
项目:Mario-Libgdx    文件:CastleLevelEndingSceneHandler.java   
public CastleLevelEndingSceneHandler(Mario mario, TmxMap tileMap, GameCamera camera,
         Array<IScrollingBackground> scrollingBbackgrounds, BitmapFont font, SpriteBatch spriteBatch,
        OrthogonalTiledMapRenderer renderer, Stage stage, Batch batch) {
    super(mario, tileMap, camera, scrollingBbackgrounds, font, spriteBatch, renderer, stage, batch);
    for (int i = 0; i < tileMap.getTileLayer().getWidth(); i++) {
        for (int j = 0; j < tileMap.getTileLayer().getHeight(); j++) {
            Cell cell = tileMap.getTileLayer().getCell(i, j);
            if (cell != null) {
                TiledMapTile tile = cell.getTile();
                int id = tile.getId();
                if (id==118) {
                    tileToRemove.add(new Vector2(i,j));
                }
            }
        }
    }   
    for (AbstractEnemy enemy : tileMap.getEnemies()) {
        if (enemy.getEnemyType()==EnemyTypeEnum.BOWSER) {
            if (!enemy.isKilled()) {
                bowser = enemy;                 
            } 
        }
    }
    updateEnemies = true;       
}
项目:Mario-Libgdx    文件:AbstractCinematicSceneHandler.java   
public AbstractCinematicSceneHandler(Mario mario, TmxMap tileMap, GameCamera camera,
         Array<IScrollingBackground> backgrounds, BitmapFont font, SpriteBatch spriteBatch,
        OrthogonalTiledMapRenderer renderer, Stage stage, Batch batch) {
    super();
    this.mario = mario;
    this.tileMap = tileMap;
    this.camera = camera;
    this.scrollingBackgrounds = backgrounds;
    this.font = font;
    this.spriteBatch = spriteBatch;
    this.renderer = renderer;
    this.stage = stage;
    this.batch = batch;
    this.updateItems = true;    
    this.updateEnemies = false;
    this.updatePlateforms = false;
    this.updateSfxSprites = true;
}
项目:ZombieCopter    文件:Level.java   
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);
}
项目:SupaBax    文件:GameScreen.java   
/**
 * 
 */
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);
}
项目:libgdxcn    文件:TiledMapDirectLoaderTest.java   
@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);
}
项目:libgdxcn    文件:TideMapDirectLoaderTest.java   
@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);
}
项目:libgdxcn    文件:TiledMapAtlasDirectLoaderTest.java   
@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 AtlasTmxMapLoader().load("data/maps/tiled-atlas-processed/test.tmx");
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
项目:libgdxcn    文件:TideMapAssetManagerTest.java   
@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 TideMapLoader(new InternalFileHandleResolver()));
    assetManager.load("data/maps/tide/Map01.tide", TiledMap.class);
    assetManager.finishLoading();
    map = assetManager.get("data/maps/tide/Map01.tide");
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
项目:SaveUA    文件:ScrollMap.java   
/**
 *
 * @param tileMap ширина, высота и размер тайла берется из первого слоя:
 * TiledMapTileLayer bg = (TiledMapTileLayer) tileMap.getLayers().get(0);
 * cellSize = (int) bg.getTileHeight(); mapW = bg.getWidth(); mapH =
 * bg.getHeight();
 */
public ScrollMap(TiledMap tileMap) {
    mapCamera = new OrthographicCamera();
    mapRenderer = new OrthogonalTiledMapRenderer(tileMap, 1f/* / cellSize */);
    stageViewport = new ScreenViewport(new OrthographicCamera());
    TiledMapTileLayer bg = (TiledMapTileLayer) tileMap.getLayers().get(0);
    cellSize = (int) bg.getTileHeight();
    mapW = bg.getWidth() * cellSize;
    mapH = bg.getHeight() * cellSize;
    mapHolder = new Actor();
    mapHolder.setSize(mapW, mapH);
    scrollPane = new ScrollPane(mapHolder);
    scrollPane.setOverscroll(false, false);
    root = new Table();
    root.setFillParent(true);
    root.add(scrollPane).fill().expand();
    stage = new Stage(stageViewport);
    stage.addActor(root);
    im = new InputMultiplexer();
    gameBatch = mapRenderer.getSpriteBatch();
    sprites = new Array<Sprite>();
    gestureDetector = new GestureDetector(gestureListener);
}
项目:mobius    文件:LevelEntityFactory.java   
protected Entity generateLevelEntity(TiledMap map, float x, float y) {
    Entity e = world.createEntity();

    Position p = world.createComponent(Position.class);
    p.position.set(x, y);
    e.addComponent(p);

    TiledRenderable r = world.createComponent(TiledRenderable.class);
    r.map = map;
    r.renderer = new OrthogonalTiledMapRenderer(r.map, 1.0f, batch);
    r.renderableLayers = new String[3];
    r.renderableLayers[0] = "floor";
    r.renderableLayers[1] = "levelnumber";
    r.renderableLayers[2] = "text";
    e.addComponent(r);

    e.addToWorld();
    e.disable();
    return e;
}
项目:libgdx    文件:SpriteManager.java   
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);
}
项目:NicolasRage    文件:GameScreen.java   
protected void setUp(Game screenSwitcher)
{
    world = new World(new Vector2(0, 0), true);
    world.setContactListener(this);
    DebugRenderer = new Box2DDebugRenderer();
    player = new Player(world, 15, 15, 1);
    camera = new GameCamera(1f, 1f * ((float) Gdx.graphics.getHeight()) / Gdx.graphics.getWidth(), player);
    camera.zoom = 10;
    camera.update();
    area = new Area("map.tmx");
    area.addToWorld(world, rand);
    mapRenderer = new OrthogonalTiledMapRenderer(area.getMap(), 1 / 256f);
    camera.zoom += 10;
    camera.update();
    game = screenSwitcher;
    batch = new SpriteBatch();
    batch.setProjectionMatrix(camera.combined);
}
项目:libgdx-maps    文件:MapManager.java   
public MapManager(AbstractTileInfo info, TileListener listener, ByteCache cache, float width, float height, float mapX, float mapY) {
      this.info = info;
      this.listener = listener;
      this.cache = cache;

this.width = width;
this.height = height;
this.mapX = mapX;
this.mapY = mapY;

tiledMap = new TiledMap();
renderer = new OrthogonalTiledMapRenderer(tiledMap, 1f);
buffer = new FrameBuffer(Pixmap.Format.RGB888, (int)width, (int)height, false);
camera = new OrthographicCamera(width, height);
camera.position.set(width*0.5f, height*0.5f, 0);

mapRegion = new TextureRegion();

// Initialize map
updateTiles();
  }
项目:artemis-odb-contrib    文件:TerrainManager.java   
@Override
protected void setup(Entity e, Terrain terrain, TerrainAsset asset) {
    if (terrain.id == null ) {
        throw new RuntimeException("TerrainManager: terrain.id is null.");
    }
    asset.map = loader.load(terrain.id);
    asset.renderer = new OrthogonalTiledMapRenderer(asset.map);
    //asset.layers = map.getLayers().getByType(TiledMapTileLayer.class);
    final MapProperties properties = asset.map.getProperties();
    asset.width = properties.get("width", Integer.class);
    asset.height = properties.get("height", Integer.class);
    asset.tileWidth = properties.get("tilewidth", Integer.class);
    asset.tileHeight = properties.get("tileheight", Integer.class);

    // set unitialized size to asset.
    if (!mSize.has(e)) {
        mSize.create(e).set(asset.pixelWidth(), asset.pixelHeight());
    }
}
项目:Elementorum    文件:Level.java   
public Level() {
    super("Game");

    cam = new OrthographicCamera();
    // Setup camera viewport
    cam.setToOrtho(false, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    cam.update();

    batch = new SpriteBatch();
    // Load map
    map =  new TmxMapLoader().load("maps/Lvl1.tmx");
    mapRenderer = new OrthogonalTiledMapRenderer(map);

    // Load walls as rectangles in an array
    MapObjects wallobjects = map.getLayers().get("Walls").getObjects();
    for(int i = 0; i < wallobjects.getCount(); i++) {
        RectangleMapObject obj = (RectangleMapObject) wallobjects.get(i);
        Rectangle rect = obj.getRectangle();
        walls.add(new Rectangle(rect.x, rect.y, 16, 16));
    }
    Texture[] tex = new Texture[]{new Texture("sprites/Player_Side_Left.png"),new  Texture("sprites/Player_Side_Right.png"), new Texture("sprites/Player_Behind_1.png"), new Texture("sprites/Player_Behind_2.png"),new Texture("sprites/Player_Forward1.png"),new Texture("sprites/Player.png")};
    player = new Player("sprites/Player.png", 120, 120, walls, tex);
    wall = new Texture("tiles/Wall.png");
}
项目:cocos2d-java    文件:TMXTiledMap.java   
/** 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;
}
项目:MMORPG_Prototype    文件:PlayState.java   
public PlayState(StateManager states, Client client)
{
    this.client = client;
    inputHandler = new NullInputHandler();
    player = new NullPlayer();
    this.states = states;
    camera.setToOrtho(false);
    camera.viewportWidth = CAMERA_WIDTH;
    camera.viewportHeight = CAMERA_HEIGHT;

    mapRenderer = new OrthogonalTiledMapRenderer(map, Assets.getBatch());
}
项目:skycity    文件:GameScreen.java   
public GameScreen(SkyCity skyCity) {
    super(skyCity);
    state = InputState.GAME;
    hud = new Hud(skyCity.batch);
    chat = new Chat(skyCity.batch);

    mapCamera = new OrthographicCamera(SCREEN_WIDTH, SCREEN_HEIGHT);
    gamePort = new FitViewport(SCREEN_WIDTH, SCREEN_HEIGHT, mapCamera);

    renderer = new OrthogonalTiledMapRenderer(Assets.getInstance().getTiledMap(), skyCity.batch);

    mapCamera.position.set(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 0);
    renderer.setView(mapCamera);

}
项目:Dungeon    文件:Main.java   
public void handleInput () {
    if (Gdx.input.isKeyJustPressed(Keys.P)) {show_debug = !show_debug;}
    if (Gdx.input.isKeyJustPressed(Keys.O)) {this.tiledMapRenderer = new OrthogonalTiledMapRenderer (currentLevel.getLevel());}
    if (Gdx.input.isKeyJustPressed(Keys.I)) {currentLevel = level2;}
    if (Gdx.input.isKeyPressed    (Keys.K)) {player.setCurrentHealth(player.getCurrentHealth() - 2);}
    if (Gdx.input.isKeyPressed    (Keys.L)) {player.setCurrentHealth(player.getCurrentHealth() + 2);}
    if (Gdx.input.isKeyPressed    (Keys.N)) {player.setCurrentMana  (player.getCurrentMana() - 2);}
    if (Gdx.input.isKeyPressed    (Keys.M)) {player.setCurrentMana  (player.getCurrentMana() + 2);}
}
项目:QuackHack    文件:PlayScreen.java   
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));

}
项目:gdxjam-ugg    文件:MapController.java   
public MapController loadMap(String tmxFile, Batch batch, boolean atlas) {
    if(atlas)
        this.map = atlasTmxMapLoader.load(tmxFile);
    else
        this.map = maploader.load(tmxFile);
    renderer = new OrthogonalTiledMapRenderer(map, batch);
    loadObjects();
    return this;
}
项目:EvilBunnyGod    文件:WorldRenderer.java   
public WorldRenderer(World world) {
    shapeDebugger = new ShapeRenderer();
    this.world = world;
    //loadAssets();
    Assets.init();
    initGameObjects();
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, Gdx.graphics.getWidth() / (float) World.TILE_SIZE, Gdx.graphics.getHeight() / (float) World.TILE_SIZE);
    camera.zoom += 2;

    //GUI camera
    gestureBatch = new SpriteBatch();
    cameraGUI = new OrthographicCamera(Constants.VIEWPORT_GUI_WIDTH, Constants.VIEWPORT_GUI_HEIGHT);
    cameraGUI.position.set(0, 0, 0);
    cameraGUI.setToOrtho(false); //flip y-axis
    font = new BitmapFont(Gdx.files.internal("mainmenu/default.fnt"),
            Gdx.files.internal("mainmenu/default.png"), false);

    tileMapRenderer = new OrthogonalTiledMapRenderer(world.map, 1f / World.TILE_SIZE, batch);

    // figure out which layer has which id, idiotic
    for (int i = 0; i < world.map.getLayers().getCount(); i++) {
        MapLayer layer = world.map.getLayers().get(i);
        if (layer.getName().equals("floor")) LAYER_FLOOR = i;
    }
}
项目:freeze-fire-tag    文件:Board.java   
private void loadMap(Camera camera, String mapName)
{
    map = new TmxMapLoader().load(mapName);
    renderer = new OrthogonalTiledMapRenderer(map, 1 / Constants.BLOCK_SIZE);
    renderer.setView((OrthographicCamera) camera);
    mapLayers = map.getLayers();
}
项目:Entitas-Java    文件:TiledRendererSystem.java   
@Override
public void initialize() {
    this.cam = context.getCamera().camera;
    Tiled tiled = context.getTiled();
    TiledMap tiledMap = assetsManager.getMap(tiled.tileMapName);
    this.tiledRenderer = new OrthogonalTiledMapRenderer(tiledMap, tiled.unitScale);

}
项目:AI_TestBed_v3    文件:Level.java   
public void restart() {

    setBatch(new SpriteBatch());

    loadLevel(getLevel());

    setMapRenderer(new OrthogonalTiledMapRenderer(map));

    //systems tick in order added by default
    WorldConfiguration worldConfig = new WorldConfiguration();
    worldConfig.setSystem(new WorldTimer(GameSettings.tickDelayGame));
    worldConfig.setSystem(new GameInput(GameSettings.tickDelayGame));
    //process world
    worldConfig.setSystem(new WorldSim(GameSettings.tickDelayGame));
    //process physics
    worldConfig.setSystem(new PhysicsWrapper(GameSettings.tickDelayGame));
    //process entities that respond to physics
    worldConfig.setSystem(new SpriteSim(GameSettings.tickDelayGame));
    worldConfig.setSystem(new MapRender());
    worldConfig.setSystem(new SpriteRender());
    worldConfig.setSystem(new SpriteRenderHUD());
    worldConfig.setSystem(new HUDRender());

    worldArtemis = new World(worldConfig);

    worldBox2D = new com.badlogic.gdx.physics.box2d.World(new Vector2(0, 0), true);

       loadLevelObjects();

    respawnPlayer();
}
项目:OdysseeDesMaths    文件:Terrain.java   
public Terrain() {
    int height, width;

    // Récupération d'une map
    this.map = new TmxMapLoader().load("arrivee_remarquable/map.tmx");
    this.renderer = new OrthogonalTiledMapRenderer(map);

    // Récupération de ses dimensions
    width = Integer.valueOf((String)map.getProperties().get("width"));
    height = Integer.valueOf((String)map.getProperties().get("height"));
    this.cases = new Case[width][height];

    // Récupération des layers nécessaires
    TiledMapTileLayer obstaclesLayer = (TiledMapTileLayer)map.getLayers().get("obstacles");

    // Création des cases
    for (int i=0; i < width; i++) {
        for (int j=0; j < height; j++) {
            cases[i][j] = new Case(i, j, obstaclesLayer.getCell(i,j) != null);
        }
    }

    // Récupération des points de départ et d'arrivée
    String[] mapDepart = ((String)map.getProperties().get("start")).split(",");
    String[] mapFin = ((String)map.getProperties().get("end")).split(",");
    this.depart = cases[Integer.valueOf(mapDepart[0])][Integer.valueOf(mapDepart[1])];
    this.fin = cases[Integer.valueOf(mapFin[0])][Integer.valueOf(mapFin[1])];
}
项目:libgdx_mario    文件:PlayScreen.java   
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>();
}
项目:killingspree    文件:WorldRenderer.java   
public void loadLevel(String level, boolean isServer, String name) {
    this.isServer = isServer;
    map = new TmxMapLoader().load(level);
    TiledMapTileLayer layer = (TiledMapTileLayer) map.
                                getLayers().get("terrain");
    VIEWPORT_WIDTH = (int) (layer.getTileWidth() * layer.getWidth());
    VIEWPORT_HEIGHT = (int) (layer.getTileHeight() * layer.getHeight());
    viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, camera);
    renderer = new OrthogonalTiledMapRenderer(map);
    name = name.trim();
    if (name.length() == 0)
        name = "noname";
    if (name.length() >= 10){
        name = name.substring(0, 10);
    }
    ClientDetailsMessage clientDetails = new ClientDetailsMessage();
    clientDetails.name = name;
    clientDetails.protocolVersion = Constants.PROTOCOL_VERSION;
    if (isServer) {
        MapLayer collision =  map.
                getLayers().get("collision");
        for(MapObject object: collision.getObjects()) {
            worldManager.createWorldObject(object);
        }
        worldManager.addIncomingEvent(MessageObjectPool.instance.
                eventPool.obtain().set(State.RECEIVED, clientDetails));
    } else {
        client.sendTCP(clientDetails);
    }
    controls = new onScreenControls();

}
项目:rts-engine    文件:RTSAbstractMap.java   
public RTSAbstractMap(RTSGame game, String tiledMapPath, boolean useFogOfWar) {
super();
this.game = game;

// Lets initialize the tiled map
tiledMap = new TmxMapLoader().load(tiledMapPath);

MapLayers mapLayers = tiledMap.getLayers();
baseLayer = (TiledMapTileLayer) mapLayers.get(BASE_LAYER_NAME);
baseLayerOverlay = (TiledMapTileLayer) mapLayers.get(BASE_LAYER_OVERLAY_NAME);
MapLayer objectsLayer = mapLayers.get(OBJECTS_LAYER_NAME);
if (objectsLayer != null)
    mapObjects = objectsLayer.getObjects();

mapBatch = new SpriteBatch(100, RTSGame.game.mapShader);

// Initialize map renderer
mapRenderer = new OrthogonalTiledMapRenderer(tiledMap, mapBatch);

initializeMapGenAndRenderer();

// And now let's initialize the quadtree
map = mapGen.generateMap(tiledMap);

astar = new AStar<IBoundsObject>(map);

// Number of tiles that fit in the canvas, to render.
renderTileWidth = Gdx.graphics.getWidth() / (int) baseLayer.getTileWidth();
renderTileHeight = Gdx.graphics.getHeight() / (int) baseLayer.getTileHeight();

// Fog of war
this.useFogOfWar = useFogOfWar;
if (useFogOfWar) {
    fogOfWar = new FogOfWar((int) (baseLayer.getWidth()), (int) (baseLayer.getHeight()),
        (int) baseLayer.getTileWidth());
}
   }
项目:libgdxcn    文件:SuperKoalio.java   
@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);
}
项目:libgdxcn    文件:TiledMapBench.java   
@Override
public void create () {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 320, 320);
    camera.update();

    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);

    font = new BitmapFont();
    batch = new SpriteBatch();

    {
        tiles = new Texture(Gdx.files.internal("data/maps/tiled/tiles.png"));
        TextureRegion[][] splitTiles = TextureRegion.split(tiles, 32, 32);
        map = new TiledMap();
        MapLayers layers = map.getLayers();
        for (int l = 0; l < 20; l++) {
            TiledMapTileLayer layer = new TiledMapTileLayer(150, 100, 32, 32);
            for (int x = 0; x < 150; x++) {
                for (int y = 0; y < 100; y++) {
                    int ty = (int)(Math.random() * splitTiles.length);
                    int tx = (int)(Math.random() * splitTiles[ty].length);
                    Cell cell = new Cell();
                    cell.setTile(new StaticTiledMapTile(splitTiles[ty][tx]));
                    layer.setCell(x, y, cell);
                }
            }
            layers.add(layer);
        }
    }

    renderer = new OrthogonalTiledMapRenderer(map);

}
项目:libgdx    文件:GameScreen.java   
@Override
public void show() {

    // Carga toda la pantalla desde cero
    if (empiezaPartida) {
        // Evita que nos fuerce a que el fichero de tiles sea potencia de 2
        Texture.setEnforcePotImages(false);
        // Crea el mapa y el renderizador
        map = new TmxMapLoader().load("levels/level1.tmx");
        mapRenderer = new OrthogonalTiledMapRenderer(map);

        // Crea una cámara y muestra 30x20 unidades del mundo
        camera = new OrthographicCamera();
        camera.setToOrtho(false, 30, 20);
        camera.update();

        // Obtiene la referencia a la capa de terreno del mapa
        TiledMapTileLayer collisionLayer = (TiledMapTileLayer) map.getLayers().get(0);
        // Crea el jugador y lo posiciona al inicio de la pantalla
        player = new Player(collisionLayer, game);
        // posición inicial del jugador
        player.position.set(0 * map.getProperties().get("tilewidth", Integer.class), 2 * map.getProperties().get("tileheight", Integer.class) + 32);

        // Coloca tiles animados
        TiledMapManager.animateTiles(map, collisionLayer, "coin", 4);
        TiledMapManager.animateTiles(map, collisionLayer, "plant", 3);
        TiledMapManager.animateTiles(map, collisionLayer, "box", 4);

        // Música durante la partida
        game.levelSound.loop();

        empiezaPartida = false;
    }
}
项目:Missing_Words    文件:World.java   
public World(MissingWords missingWords) {
    this.missingWords = missingWords;

    t = new Timer();

    /* Cargamos el mapa */
    tileMap = new TmxMapLoader().load("minigame.tmx");

    /* Creamos el MapRenderer y lo asociamos a nuestra camara del stage */
    renderer = new OrthogonalTiledMapRenderer(tileMap, missingWords.getSB());
    renderer.setView((OrthographicCamera) missingWords.getGameScreen().getStage().getViewport().getCamera());

    /* Creamos las losetas */
    playerTile = new StaticTiledMapTile(new TextureRegion((MissingWords.myManager.get("player.png", Texture.class))));
    npcTile = new StaticTiledMapTile(new TextureRegion((MissingWords.myManager.get("npc.png", Texture.class))));
    transparentTile = new StaticTiledMapTile(new TextureRegion((MissingWords.myManager.get("transparentTile.png", Texture.class))));        
    holeTile = new StaticTiledMapTile(new TextureRegion((MissingWords.myManager.get("holeGrass.png", Texture.class))));
    bothPlayers = new StaticTiledMapTile(new TextureRegion((MissingWords.myManager.get("bothPlayers.png", Texture.class))));

    /* Obtenemos las capas del mapa */
    pathLayer = (TiledMapTileLayer) tileMap.getLayers().get("Path");
    tokenLayer = (TiledMapTileLayer) tileMap.getLayers().get("Tokens");

    generateHoles();

    createSquares();

    placePlayers();
}