You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I managed to solve my problem
I used this code from tiled as reference
I dont know if it breaks while scale/rotate objects in tiled, but if works for me)
consttilemap=this.add.tilemap(Timemaps.test);consttileWidth=tilemap.tileWidth;consthalfTileWidth=tileWidth*0.5;consttileHeight=tilemap.tileHeight;constoriginX=tilemap.height*tileWidth*0.5;consttile_grass=tilemap.addTilesetImage('tile_grass',Images.tile_grass)!;constlayer=tilemap.createLayer('Tile Layer 1',tile_grass)!;//! Layer position fixconsttilemapWidth=tilemap.widthInPixels;consthalfTilemapWidth=tilemapWidth*0.5;layer.setPosition(halfTilemapWidth-halfTileWidth,0);constobjects=tilemap.objects[0].objects;for(leti=0;i<objects.length;i++){//! Ref: https://github.com/mapeditor/tiled/blob/12ca7077d3d5cd9655929030092681a986dd749a/src/libtiled/isometricrenderer.cpp#L495-L505constobject=objects[i];consttileY=object.y!/tileHeight;consttileX=object.x!/tileHeight;constx=(tileX-tileY)*tileWidth*0.5+originX;consty=(tileX+tileY)*tileHeight*0.5;constsprite=this.add.sprite(x,y,(Imagesasany)[object.name]);sprite.setOrigin(0.5,1);}
About "Layer position fix" part, layer getBounds doesn't match its rendered position
Version
Description
I wanted to create the tilemap objects myself and copied logic from here
But the positions of the objects were not correct
I created a new map and got exactly the same result with createFromObjects
Example Test Code
Tiled JSON
The text was updated successfully, but these errors were encountered: