0
votes

I am creating my own TMX map in Tiled. I've imported some Patterns Set and set them in the corresponding Tile Layer. The map looks good in Tiled but when I load it in my level using Andengine, the images displayed in each tile are different to the ones I used in the Tiled editor (another tile from the matrix is displayed instead of the tile I chose in the editor)

The code use it to load is the normal one:

final TMXLayer mTMXLayer = this.mTMXTiledMap.getTMXLayers().get(0);
    mScene.attachChild(mTMXLayer);

I don't know if it matters, but the tiles are 70x70 and when loading them I have to include an spacing of 2px. The thing is the example I took this from works perefctly but the tiles there are 32x32 and no spacing. The compression is gzip and the paths are correct. Thank you so much!

1

1 Answers

0
votes

I have used TMX maps in my game Mr. Dandelion and I use different way of loading that the normal one.

final TMXLoader tmxLoader = new TMXLoader(ResourceManager.getInstance().activity.getAssets(),
        ResourceManager.getInstance().engine.getTextureManager(), 
        TextureOptions.BILINEAR_PREMULTIPLYALPHA, 
        ResourceManager.getInstance().vbom);

String name = ... // here I just create a name of my level to load
tmxMap = tmxLoader.loadFromAsset(name);
scene.attachChild(tmxMap);
tmxMap.setOffsetCenter(0, 0);

And that's it. As you can see in the code I am attaching the whole TMX map. It contains more than just the TMX Tiles layer, I have several object layers. Also I use 128x128 tiles (I think) with 2px padding.

If this won't work for you, post a screenshot of what is actually happening. If the problem is that different tile is shown, than it's not a problem of the sizes or the padding. You would see a completely garbled tiles in that case.

Also make sure that you are using both AndEngine and the TMX Extension from the branch (GLES2 AnchorCenter recommended).