1

I've got an issue when I try to load a .tmx file in a CCTileMap CocosSharp object.

Here is the code :

                layer2 = new CCLayer();
                CCTileMap tileMap;
                tileMap = new CCTileMap("TestCCS.Droid.Assets/TileMaps/TestTile2.tmx");

                layer2.AddChild(tileMap);
                this.AddChild(layer2);

I tried :

                tileMap = new CCTileMap("TestCCS.Droid.Assets.TileMaps.TestTile2.tmx");

or :

                tileMap = new CCTileMap("Assets.TileMaps.TestTile2.tmx");

The TestTile2.tmx file build Action is set to "Embedded resource"

And this my solution explorer :

enter image description here

Thank you for your help.

Alexus
  • 276
  • 1
  • 5
  • 22

1 Answers1

1

Found a way to load the TileMap file.

The solution I found :

  • save the TileMap file in .xml format in Tiled software.
  • save the .tsx file in .xml format.

  • I use this code to load the tile map file :

                layer2 = new CCLayer();
                CCTileMap tileMap;
    
                CCTileMapInfo mi = new CCTileMapInfo("TestTile2.xml");
                tileMap = new CCTileMap(mi); 
    
                layer2.AddChild(tileMap);
                this.AddChild(layer2);
    

Where "TestTile2.xml" is an android asset.

  • every tile of layers must have an Id. I had tiles without "gid", I had to set them to a transparent gid.

Hope this will help others !

Alexus
  • 276
  • 1
  • 5
  • 22