-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object positions aren't correct for isometric maps. #242
Comments
After even more testing, the positions of the rendering are correct in relation to the pixel coordinates exported from Tiled, but only in ortographic, and only if there's no scaling of the |
Some Tiled objects act a little funny in that when you place them, their
location is static and if you move any of their vertices, those vertices
get offset values. So even if you move all the vertices of an object to a
far off place, the object's "location" remains where it was initialized.
Could this be the issue you're seeing?
…---
Landon Manning
[email protected]
On Mon, 14 Sep 2020 at 03:27, Mackan ***@***.***> wrote:
After even more testing, the positions of the rendering are correct in
relation to the pixel coordinates exported from Tiled, but only in
ortographic, and only if there's no scaling of the Map:draw function.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#242 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEQD7APJXE5M3RKSFJKWHLSFWZWBANCNFSM4RKRFYIQ>
.
|
I'm not entirely sure, as it seems the objects are using the ortographic coordinates exported from Tiled, but aren't being converted into isometric coords properly. |
After some help from @bjorn in the Tiled Discord, I've managed to get a workaround going; function convertScreenToTile (x, y, tileHeight)
local xTile = math.ceil(x / tileHeight) - 2
local yTile = math.ceil(y / tileHeight) - 1
return xTile, yTile
end
local tileX, tileY = convertScreenToTile(object.x, object.y, map.tileheight)
local xPos, yPos = map:convertTileToPixel(tileX, tileY, map.tileheight) |
The proposed solution by @Sven65 does not work for me. The object is still drawn outside the corresponding object layer. Also the convertTileToPixel does not accept that third argument as per sti init.lua file . Any suggestions ? |
can you share your code and map files? |
Describe the bug
As the title says, the position of the objects aren't correct.
To Reproduce
Steps to reproduce the behavior:
** Example Code **
Expected behavior
I expect the object to line up properly in the tile coords.
Screenshots
Tiled:
Game:
Version
STI 1.2.3.0
The text was updated successfully, but these errors were encountered: