3

I'm adding a CCTMXTiledMap to my Android project but it's not showing on the screen.

This is what I tried. I created the map with Tiled, changed the compression in Base64 gzip to get rid of the indexOutOfBounds issue, and loading it with this generic code:

CCTMXTiledMap map = CCTMXTiledMap.tiledMap("sewer.tmx");
addChild(map);

I also tried different values in the addChild method, such as

addChild(map, 0)

or -1, or 1, but no luck.

Here's some debug data:

map = <instance of class org.cocos2d.layers.CCTMXTiledMap| Tag = -1>
map bounding box d=((0.0, 0.0),(768.0, 768.0))
map bounding anchor point =(0.0, 0.0)
map bounding position =(0.0, 0.0)
map bounding content size =<768.0, 768.0>
chidren =[<instance of class org.cocos2d.layers.CCTMXLayer| Tag = 0>]

My tmx file:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="32" height="32" tilewidth="24" tileheight="24">
<tileset firstgid="1" name="sewer_tileset_large.png" tilewidth="24" tileheight="24">
<image source="sewer_tileset_large.png" trans="ff00ff" width="1920" height="2170"/>
</tileset>
<layer name="Tile Layer 1" width="32" height="32">
<data encoding="base64" compression="gzip">
    H4sIAAAAAAAAC+3BAQ0AAADCoPdPbQ8HFAAAAPBuEQAcxwAQAAA=
</data>
</layer>

The png image, sewer_tileset_large.png is in the assets folder, next to the sewer.tmx file. I noticed that in the tmx file generated by Tiled the .png extension is omitted, so I added it manually. But still no luck.

What am I missing?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Eddy
  • 3,533
  • 13
  • 59
  • 89
  • The tileset name is the filename without extension, the actual texture reference is the image source attribute. You added the tileset png file to the project, right? – CodeSmile May 14 '13 at 16:23
  • Yes, I did, into the assets folder, right where the tileset file is, and yes, I saw that it's the image source attribute. I'm not near a work computer right now but I'm thinking maybe I should add the map to the CCCene? What I did was add it to the main layer. – Eddy May 14 '13 at 18:18
  • Adding it to the scene didn't change anything. I also tried removing the image from the project, hoping to at least get an error message, but no suck luck. Obviously I'm missing something simple. @LearnCocos2D could you help? I'm despairing here. – Eddy May 15 '13 at 07:25
  • One more bit of information: the way I created the tmx file in Tiles is by going to File > New, choosing orthogonal, and adjusting the tiles numbers, and tile size so that they fit the size of the sewer_tileset image. Then I clicked OK and went to Map > New Tileset, selected the image from my Android's assets folder, selected "Use Transparent Color," changed nothing else and clicked OK. Then I saved the tmx file in my assets folder, and refreshed the Eclipse project to make sure everything is in place. Seems pretty generic, but it's not working. – Eddy May 15 '13 at 07:29

0 Answers0