Reputation: 29
I've tried using different tiled maps and using the zlib compression type. I have the png file and the tmx file inside the assets folder under android.
If you need anymore information I will reply. Any help is appreciated. Thanks
package com.mm.test1;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
public class TestOne extends ApplicationAdapter {
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;
@Override
public void create () {
map = new TmxMapLoader().load("grass1.tmx");
renderer = new OrthogonalTiledMapRenderer(map);
}
@Override
public void render () {
Gdx.gl.glClearColor(0,0,0,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.render();
}
@Override
public void dispose () {
map.dispose();
renderer.dispose();
}
}
Heres the error message:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: Downloads/TilesetGrass/TilesetGrass/overworld_tileset_grass.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:149)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:96)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:86)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:67)
at com.mm.test1.TestOne.create(TestOne.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: Downloads\TilesetGrass\TilesetGrass\overworld_tileset_grass.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:146)
... 8 more
Upvotes: 1
Views: 1680
Reputation: 2037
The problem lies in the .tsx (TileSet) file.
Go into the .tsx file and change:
<image source="Downloads/TilesetGrass/TilesetGrass/overworld_tileset_grass.png" ... />
to
<image source="[relative path to your .png from asset folder]" ... />
By creating your TileSet for your TileMap you probably have choose the .png when it was still in the download folder, so your TileSet points to the Path:Downloads/TilesetGrass/TilesetGrass/overworld_tileset_grass.png
shown in your error message.
Upvotes: 1
Reputation: 11
Go to your run config of your IDE and set working directory pointed at android/assets folder. If you don't have android and you are developing for desktop you can find assets folder in core project.
Upvotes: 0
Reputation: 6057
How do you start your application? Is this a runnable jar file or do you run it via the IDE? When you start it via the IDE, you have to set the working directory to android\assets
.
Upvotes: 0