1
\$\begingroup\$

I created a map only with an image layer in tiled map editor.

Only an image layer settings

When I want to load the map the layer isn't shown. Only the background color.

enter image description here

Followed the tutorial from http://www.gamefromscratch.com/post/2014/04/16/LibGDX-Tutorial-11-Tiled-Maps-Part-1-Simple-Orthogonal-Maps.aspx

Here the code (left out empty overrides):

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;

public class Main extends ApplicationAdapter implements InputProcessor  {
TiledMap tiledMap;
OrthographicCamera camera;
TiledMapRenderer tiledMapRenderer;

@Override
public void create () {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera();
    camera.setToOrtho(false,w,h);
    camera.update();
    tiledMap = new TmxMapLoader().load("C:/Users/Robin/Desktop/map.tmx");
    tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);

    Gdx.input.setInputProcessor(this);
}

@Override
public void render () {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    camera.update();
    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render();
}
}

I added a tileset and tried again (just a little test). Only the tiles are visible: red marked the part you can see view in opengl - libgdx

Any ideas how to set the layer visible?

Greetings Kaito

\$\endgroup\$
2
  • \$\begingroup\$ Tell us what you've tried and how it's not working. Edit your question to include the information, the link to the tutorial you're following can go bad making this question not useful to future visitors. \$\endgroup\$
    – House
    Commented Dec 25, 2014 at 8:46
  • \$\begingroup\$ added screenshots and code for better understanding \$\endgroup\$
    – Kaito
    Commented Dec 25, 2014 at 19:32

1 Answer 1

3
\$\begingroup\$

When browsing the libgdx documentation (for example at http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapLayer.html), I don't see any mention of the image layer, so most likely this relatively new (and still quite limited) layer type is not supported by libgdx yet.

If you would like to see this supported in libgdx, I suggest opening an issue about it at https://github.com/libgdx/libgdx/issues

Update: This feature has been implemented in libgdx in the meantime. See https://github.com/libgdx/libgdx/issues/2741

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .