[Solved] Large tilemap doesn't completly load

[Solved] Large tilemap doesn't completly load
0.0 0


Hi all!

I’m trying to create a game using Cocos2D-X in HTML5 and a tilemap.
I also activated the capability to move my map with with the mouse and the onTouchMove event.
However, when I move my map, it appears that there is only a small rectangle of the entire map which is rendered.
If you don’t understand, my map is around 4000x4000 px (64 x 64 hexagons) and my cocos2dx frame is 1920*1080. The fact is that the rendered map is not 64 hexagons width but 32 hexagons.
And when I move the map, the map doesn’t refresh and I got my background.

By the way, to test I added some code to go to the center of the map (at x = 32 and y = 32 - hexagons) but this time again, there’s no map which is displayed, just the background. And when I grab the map to go to left bottom corner, the small rectangle of 32 hexagons width appear.

How can I fix this ?

Here is my code :
// Map code
this.map = cc.TMXTiledMap.create(“res/azeroth.tmx”);
this.addChild(this.map, 1, TAG_MAP);

var s = this.map.getContentSize();
console.log(s); // display map width / height in px : about 4000px width and height

// move map to the center of the screen
//var ms = this.map.getMapSize();
//var ts = this.map.getTileSize();
//map.runAction(cc.MoveTo.create(1.0, cc.p(~~ms.width * ts.width / 2,~~ms.height * ts.height / 2)));


Thanks a lot if you can help me.


In fact, I found the solution to my problem : I updated the Cocos2D-x engine to the latest revision (updated 9 days ago) and it works now.


Hello Erwan,

I just had a quick question about your TMX loading, are you finding that you must refresh your application before the TMX will load? I ask because when I launch my application in a browser for the first time (i.e. cache is cleared), the TMX layer does not show up. However if I hit refresh, then it’s there. No errors in web inspector.

Just curious if you’re seeing the same.


Hi Erik,

I don’t need to refresh the navigator.
In fact, in my app I have a main menu where I have action to launch my map. It takes a little time to load a 64x64 tiled map (around 10s) but my map appears.
I saw a lot of people on the Internet who had the same problem, but I’m sorry I think I can’t help you, I’m still new to Cocos2D-x html5 and I still don’t understand how all work.



Thanks Erwan, figured I’d check. I may have to delay the load until the scene is fully presented.

Currently, to work around the issue, I’ve been adding a Sprite child with a PNG of the tilemap, while loading the actual TMX file but only using it to read data behind the scenes (i.e. not adding it to the Layer.) Seems to be working okay so far as Tiled lets you export as an image as well.