@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile, com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) { Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>(); try { root = xml.parse(tmxFile); Element properties = root.getChildByName("properties"); if (properties != null) { for (Element property : properties.getChildrenByName("property")) { String name = property.getAttribute("name"); String value = property.getAttribute("value"); if (name.startsWith("atlas")) { FileHandle atlasHandle = Gdx.files.internal(value); dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class)); } } } } catch (IOException e) { throw new GdxRuntimeException("Unable to parse .tmx file."); } return dependencies; }
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle tmxFile, com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) { map = null; if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } try { map = loadMap(root, tmxFile, new AtlasResolver.AssetManagerAtlasResolver(manager)); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
@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); }
@Override public TiledMap loadSync(AssetManager manager, String fileName, FileHandle file, com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) { if (parameter != null) { setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); } return map; }
@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(); AtlasTiledMapLoaderParameters params = new AtlasTiledMapLoaderParameters(); params.forceTextureFilters = true; params.textureMinFilter = TextureFilter.Linear; params.textureMagFilter = TextureFilter.Linear; assetManager = new AssetManager(); assetManager.setErrorListener(new AssetErrorListener() { @Override public void error (AssetDescriptor asset, Throwable throwable) { errorMessage = throwable.getMessage(); } }); assetManager.setLoader(TiledMap.class, new AtlasTmxMapLoader(new InternalFileHandleResolver())); assetManager.load(fileName, TiledMap.class); }
public MapController(EngineController engineCtrl, CameraController cameraPlay){ this.oEngineCtrl = engineCtrl; this.maploader = new TmxMapLoader(); this.atlasTmxMapLoader = new AtlasTmxMapLoader(); }