Skip to content

Object positions aren't correct for isometric maps. #242

@Sven65

Description

@Sven65

Describe the bug
As the title says, the position of the objects aren't correct.

To Reproduce
Steps to reproduce the behavior:

  1. Create a 16x16 isometric map in Tiled, with tiles that measure 30*24px (w * h)
  2. Add an object point on the bottom centermost tile (15, 15), set it's name to "Test Object"
  3. Add a custom layer in your code,
  4. Set the draw function to draw a sprite that's 30 * 36px (w * h)
  5. See that it works on pixel coords (225, 225) from the exported lua from Tiled.
  6. Change the coords of the object point in Tiled to (135, 135).
  7. Export and run again.
  8. See that it doesn't line up properly.

** Example Code **

local layer = map:addCustomLayer("Layer", 3)

local obj

for k, object in pairs(map.objects) do
	if object.name == "Test Object" then
		obj = object
		break
	end
end

layer.obj = {
	sprite = love.graphics.newImage("sprite.png")
	x = obj.y,
	y = obj.x,
	ox = 0,
	oy = 0,
}

function layer:draw ()
	love.graphics.draw(
		self.obj.sprite,
		self.obj.x,
		self.obj.y,
		0,
		1,
		1,
		self.obj.ox,
		self.obj.oy
	)
end

Expected behavior
I expect the object to line up properly in the tile coords.

Screenshots

Tiled:
Tiled

Game:
Game

Version

STI 1.2.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions