TMXlayer getTileAt

Hi all, i’m noob with cocos, i have a strange problem with the method getTileAt. When i use it on a hexagonal map apparentely he delete the Hexagon.
this is the code:

auto layer = _tileMap->getLayer(“Livello tile 1”);
layer->getTileAt(Vec2(1,8));

these are the properties of the tiled map:

This is the original map showed:

and this is the map when i use the method getTileAt:

The black hexagon is the selected one with getTileAt

I use cocos2d-x-3.14.1 and i’ve tested the same code on xcode and visual studio.

Thanks in advance

Try using experimental::TMXTiledMap and see if you have the same problem

I tried it, now it works, but the map it’s completely wrong now. The tiles are in wrong places, the draw order it’s different from the old one and from the appearence in Tiled program.

Hi I have exactly the same problem. It is also easily reproducable in the cpp tests. Is this a bug? Maybe I should open an Issue on Github? Any Help appreciated :slight_smile:

Did you open a bug already?

No should I?

Please do and tag me in it. I’d be happy to look into this bug. It will help me update our TMX docs at the same time. Include pictures of results with original TMXTiledMap class and after using experimental::TMXTiledMap class. Basically what you have here but with a few more things.

I have created the issue https://github.com/cocos2d/cocos2d-x/issues/18773
Many thanks

Hi @slackmoehrle have you seen the Issue? Are you looking into this? Or do you need any more Information?

I am working on this.

I dunno if this will help you but, can you use this in the meantime?

uint32_t* tiles = tmxLayer->getTiles();
int tileIdx = x + (y * tmxLayer->getLayerSize().width);

// optional: subtract 1 to make it match the value reported inside Tiled editor
int tileId = tiles[tileIdx] - 1;