@Override public void create () { atlasTmxMapLoader = new AtlasTmxMapLoader(new InternalFileHandleResolver()); params = new AtlasTmxMapLoader.AtlasTiledMapLoaderParameters(); params.generateMipMaps = false; params.convertObjectToTileSpace = false; params.flipY = true; viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT); cam = (OrthographicCamera)viewport.getCamera(); map = atlasTmxMapLoader.load(TMX_LOC, params); mapRenderer = new OrthogonalTiledMapRenderer(map, UNIT_SCALE); }
/** May return null. */ protected FileHandle loadAtlas (Element root, FileHandle tmxFile) throws IOException { Element e = root.getChildByName("properties"); if (e != null) { for (Element property : e.getChildrenByName("property")) { String name = property.getAttribute("name", null); String value = property.getAttribute("value", null); if (name.equals("atlas")) { if (value == null) { value = property.getText(); } if (value == null || value.length() == 0) { // keep trying until there are no more atlas properties continue; } return getRelativeFileHandle(tmxFile, value); } } } FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); return atlasFile.exists() ? atlasFile : null; }
public TiledMap load (String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = loadAtlas(root, tmxFile); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
String elementName = element.getName(); if (elementName.equals("properties")) { loadProperties(map.getProperties(), element); } else if (elementName.equals("tileset")) { loadTileset(map, element, tmxFile, resolver); } else if (elementName.equals("layer")) { loadTileLayer(map, map.getLayers(), element); } else if (elementName.equals("objectgroup")) { loadObjectGroup(map, map.getLayers(), element);
FileHandle tsx = getRelativeFileHandle(tmxFile, source); try { element = xml.parse(tsx); imageWidth = imageElement.getIntAttribute("width", 0); imageHeight = imageElement.getIntAttribute("height", 0); image = getRelativeFileHandle(tsx, imageSource); imageWidth = imageElement.getIntAttribute("width", 0); imageHeight = imageElement.getIntAttribute("height", 0); image = getRelativeFileHandle(tmxFile, imageSource); FileHandle atlasHandle = getRelativeFileHandle(tmxFile, atlasFilePath); atlasHandle = resolve(atlasHandle.path()); TextureAtlas atlas = resolver.getAtlas(atlasHandle.path()); String regionsName = name; loadProperties(tile.getProperties(), properties); loadObject(map, tile, objectElement); loadProperties(tile.getProperties(), properties); loadProperties(tileset.getProperties(), properties);
public TiledMap load (String fileName) { return load(fileName, new AtlasTiledMapLoaderParameters()); }
@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); }
@Override public void loadAsync (AssetManager manager, String fileName, FileHandle tmxFile, 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); } }
String elementName = element.getName(); if (elementName.equals("properties")) { loadProperties(map.getProperties(), element); } else if (elementName.equals("tileset")) { loadTileset(map, element, tmxFile, resolver); } else if (elementName.equals("layer")) { loadTileLayer(map, map.getLayers(), element); } else if (elementName.equals("objectgroup")) { loadObjectGroup(map, map.getLayers(), element);
FileHandle tsx = getRelativeFileHandle(tmxFile, source); try { element = xml.parse(tsx); imageWidth = imageElement.getIntAttribute("width", 0); imageHeight = imageElement.getIntAttribute("height", 0); image = getRelativeFileHandle(tsx, imageSource); imageWidth = imageElement.getIntAttribute("width", 0); imageHeight = imageElement.getIntAttribute("height", 0); image = getRelativeFileHandle(tmxFile, imageSource); FileHandle atlasHandle = getRelativeFileHandle(tmxFile, atlasFilePath); atlasHandle = resolve(atlasHandle.path()); TextureAtlas atlas = resolver.getAtlas(atlasHandle.path()); String regionsName = name; loadProperties(tile.getProperties(), properties); loadObject(map, tile, objectElement); loadProperties(tile.getProperties(), properties); loadProperties(tileset.getProperties(), properties);
public TiledMap load (String fileName) { return load(fileName, new AtlasTiledMapLoaderParameters()); }
@Override public void loadAsync (AssetManager manager, String fileName, FileHandle tmxFile, 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 () { atlasTmxMapLoader = new AtlasTmxMapLoader(new InternalFileHandleResolver()); params = new AtlasTmxMapLoader.AtlasTiledMapLoaderParameters(); params.generateMipMaps = false; params.convertObjectToTileSpace = false; params.flipY = true; viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT); cam = (OrthographicCamera)viewport.getCamera(); map = atlasTmxMapLoader.load(TMX_LOC, params); mapRenderer = new OrthogonalTiledMapRenderer(map, UNIT_SCALE); }
public TiledMap load (String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = loadAtlas(root, tmxFile); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
String elementName = element.getName(); if (elementName.equals("properties")) { loadProperties(map.getProperties(), element); } else if (elementName.equals("tileset")) { loadTileset(map, element, tmxFile, resolver); } else if (elementName.equals("layer")) { loadTileLayer(map, map.getLayers(), element); } else if (elementName.equals("objectgroup")) { loadObjectGroup(map, map.getLayers(), element);
FileHandle tsx = getRelativeFileHandle(tmxFile, source); try { element = xml.parse(tsx); imageWidth = imageElement.getIntAttribute("width", 0); imageHeight = imageElement.getIntAttribute("height", 0); image = getRelativeFileHandle(tsx, imageSource); imageWidth = imageElement.getIntAttribute("width", 0); imageHeight = imageElement.getIntAttribute("height", 0); image = getRelativeFileHandle(tmxFile, imageSource); FileHandle atlasHandle = getRelativeFileHandle(tmxFile, atlasFilePath); atlasHandle = resolve(atlasHandle.path()); TextureAtlas atlas = resolver.getAtlas(atlasHandle.path()); String regionsName = name; loadProperties(tile.getProperties(), properties); loadObject(map, tile, objectElement); loadProperties(tile.getProperties(), properties); loadProperties(tileset.getProperties(), properties);
public TiledMap load (String fileName) { return load(fileName, new AtlasTiledMapLoaderParameters()); }
/** May return null. */ protected FileHandle loadAtlas (Element root, FileHandle tmxFile) throws IOException { Element e = root.getChildByName("properties"); if (e != null) { for (Element property : e.getChildrenByName("property")) { String name = property.getAttribute("name", null); String value = property.getAttribute("value", null); if (name.equals("atlas")) { if (value == null) { value = property.getText(); } if (value == null || value.length() == 0) { // keep trying until there are no more atlas properties continue; } return getRelativeFileHandle(tmxFile, value); } } } FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); return atlasFile.exists() ? atlasFile : null; }
@Override public void loadAsync (AssetManager manager, String fileName, FileHandle tmxFile, 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); }