Skip to content

Load a .tmx map and display inside a layout ? #290

Description

@MayeuldP

I'm trying to display a .tmx map that I did with Tiled Map Editor. I want to display it inside a layout (Android Mobile Application), however I didn't find any tips or tutoriel about how to do it, and I have absolutely no ideas. I did all the references to AndEngine, and my environement is correctly setup.
I just need a link or infos about how to do that.
I tried this simple piece of code :

 public class YourActivity extends SimpleBaseGameActivity {
     private TMXTiledMap tiledMap;
     private TMXLayer tmxLayer;

     @Override
     protected void onCreateResources() {
       try {
           final TMXLoader tmxLoader = new TMXLoader(getAssets(), getTextureManager(), TextureOptions.NEAREST, getVertexBufferObjectManager(), new ITMXTilePropertiesListener() {
            @Override
            public void onTMXTileWithPropertiesCreated(final TMXTiledMap tmxTiledMap, final TMXLayer tmxLayer, final TMXTile tmxTile, final TMXProperties<TMXTileProperty> tmxTileProperties) {
                    // do stuff with tiles that have properties...
            }
           });
           this.tiledMap = tmxLoader.loadFromAsset("tmx/yourMap.tmx");
           this.tiledMap.setIsometricDrawMethod(TMXIsometricConstants.DRAW_METHOD_ISOMETRIC_CULLING_PADDING);
       } catch (final TMXLoadException e) {
            Debug.e(e);
       }

     }

     @Override
     protected Scene onCreateScene() {
           this.tmxLayer = this.tiledMap.getTMXLayers().get(0);  // the 0 is just an index of the layer. It depends on how many layers you created within Tiled
           attachChild(this.tmxLayer);
     }

But I got many errors concerning this line new TMXLoader(... so maybe it's deprecated...
If you have any ideas, I would be very grateful !
Thank's for your help !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions