Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Image objects in Isometric map are placed at the wrong location when loading map
Started by stanga Nov 01 2017 07:12 AM

2 replies to this topic
mte million tile engine
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

stanga

[GLOBAL: userInfoPane.html]
stanga
  • Contributor

  • 193 posts
  • Corona SDK

We're trying to use MTE to display an isometric tile map in our game and noticed that objects are drawn in the wrong location when loading the map.

 

The drawObject function is using the following level positions when adding the sprite of the object:

levelPosX = object.x - (worldScaleX * 0.5)
levelPosY = object.y - (worldScaleX * 0.5)

However, the object.x and object.y parameters are in pixel coordinates from the tmx file, which do not align with either the screen position or the level position. 

So we need to perform some calculations to get the level position from the x and y values. 

Any idea what these calculations need to be?

 

Any help would be greatly appreciated.



[TOPIC: post.html]
#2

stanga

[GLOBAL: userInfoPane.html]
stanga
  • Contributor

  • 193 posts
  • Corona SDK

Eventually we were able to calculate the location from the x and y position:

local locX = ((object.x/2 - levelHeight * M.isoScaleMod * 0.5) / map.actualTileheight) + 1
local locY = ((object.y/2 - levelHeight * M.isoScaleMod * 0.5) / map.actualTileheight) + 1
 
and just gave locX and locY to the addSprite function instead of the levelPosX and levelPosY.


[TOPIC: post.html]
#3

graham07

[GLOBAL: userInfoPane.html]
graham07
  • Contributor

  • 256 posts
  • Corona SDK

Just a nod of thanks for posting the solution. Many folks make a post, and I come across it in a forum search, but never find the answer either.

So, thank you.




[topic_controls]
[/topic_controls]