Cocos2D-JS TMX tileset index not working (JS v3.2) [SOLVED]

On the wall layer I am using a 4x4 tileset, 8x8 for the floor. However, when Cocos renders it, it displays all of the tiles using the first tile in the tileset.

I found the bug. In initImageSize it sets the tileset’s imageSize based on the texture size, even though the texture has not been loaded. This sets it to (0,0), which causes it to always use the first tile, regardless of GID. Instead, set the tileset’s imageSize in parseXMLFile: the tileset size is part of the TMX document.

tileset.imageSize = cc.size(
  parseInt(image.getAttribute('width')),   parseInt(image.getAttribute('height')));

//this._renderCmd.initImageSize();

I think maybe you forgot to preload the tileset image.

1 Like

I was having the same problem, and I had indeed forgotten to preload the tileset image.
Thank you!!