Just wondering how I can correct a problem I’m observing with objects created on an object layer in Tiled. The positioning I’m viewing in Tiled is not reproduced within Corona. The positions are offset by x + 32 and y -32.
I.e an object I position at 100, 100 in Tiled has the pixel position (object.x and object.y) of 132, 68. 32 is half the tile width of 64.
Is there a setting I need to configure to positioning elements with a 0,0 anchor for example?
I attach the map and tiles and the code I use to load it is below
map = dusk.buildMap("level\_tilesets/levels.json") map.x = display.contentCenterX - (display.actualContentWidth/2) map.y = display.contentCenterY - (display.actualContentHeight/2) map:scale(1, 1) map.updateView() -- print(pretty.write(object\_layer.visible)) local object\_layer = map.layer["objects"] local tile\_layer = map.layer["level1"] for index, object\_type in ipairs({"wall", "enemy"}) do for object in object\_layer.typeIs(object\_type) do print(object.x .. " " .. object.y .. " " .. object.anchorX .. " " .. object.anchorY) physics.addBody(object, "static") end end
Here the object x,y, widths and heights are based on the object image properties rather than assuming they conform to the tileset which is used in the tiles layer.
Hm. I think back in the day (read: when Dusk first came out), it didn’t have so much support for object layers, and I’ve never really questioned my initial genius (:P). I’ll provide a fix for this, or, if you want, you can submit a pull request.
I don’t think it’ll break any code - it is a bug, after all. If people are relying on buggy behavior to make their game, that’s not so good :D. I think I actually fixed this in one branch of Dusk a while ago but it seems to have rolled back somehow. As long as it works correctly with your edited code, go right ahead.
Here the object x,y, widths and heights are based on the object image properties rather than assuming they conform to the tileset which is used in the tiles layer.
Hm. I think back in the day (read: when Dusk first came out), it didn’t have so much support for object layers, and I’ve never really questioned my initial genius (:P). I’ll provide a fix for this, or, if you want, you can submit a pull request.
I don’t think it’ll break any code - it is a bug, after all. If people are relying on buggy behavior to make their game, that’s not so good :D. I think I actually fixed this in one branch of Dusk a while ago but it seems to have rolled back somehow. As long as it works correctly with your edited code, go right ahead.