Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MayeuldP opened this issue Jun 30, 2017 · 0 comments
Open

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

MayeuldP opened this issue Jun 30, 2017 · 0 comments

Comments

@MayeuldP
Copy link

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant