Can someone help me understand positioning?

(First, I’ve scoured the Lime docs and tutorials and still don’t get it, so decided to ask here. Also, I’m using the latest (released) version of Lime and Corona build 715.)

There’s screenPosition and worldPosition and I can’t figure out how they relate. There’s also gridPosition and I think that’s the actual X/Y coordinates of a given tile but what are screenPosition and worldPosition?

On a related matter, here’s a chunk of code I put inside a tap event:

[lua] local mapx, mapy = map:getPosition()
map:slideToPosition(mapx, mapy, 2000)[/lua]

If I am getting the position of the map and then setting the map position to the same place, the map shouldn’t move, right? Except it does – starts moving diagonally down. I’m not getting any error messages when I run the code.

Not sure if this is related to not knowing what screen and worldPosition are, but it doesn’t help. :slight_smile:

Any hints?

Jay

[import]uid: 9440 topic_id: 22825 reply_id: 322825[/import]

Hi Jay, you are correct in that there aren’t any tutorials on this and there really should be. I have been a bit slack in the tutorial department as I have spent the majority of my time trying to sort out the performance issues. Now that Ansca have waved their magic wand and in theory fixed these issues I will be able to spend more time actually writing documentation and who knows, maybe even make a game using Lime myself :slight_smile:

Back to your question, I will start off with the World Position. This is simply the exact pixel position of an object/tile in the map based off of the origin of the top left corner.

Then there is the grid position, this is as you guessed the x/y position of a tile based on the grid set up in Tiled. You can see this position in Tiled in the bottom left of the screen when hovering over a tile.

And finally, there is the Screen Position. This is the position of the tile in relation to the top left corner of the screen and will range from 0 to display.contentWidth in X and 0 to display.contentHeight in Y.

Hopefully that makes sense but if not just give me a shout.

Graham [import]uid: 119420 topic_id: 22825 reply_id: 91176[/import]

Thanks, that helps. And I know what it’s like to be behind on documentation. (Insert innocent look here)

How about that code snippet in my original post? Any clue as to why the map would move when that code is executed?

My best guess is that getPosition returns a different type of position than the one slideToPosition needs?
Jay
[import]uid: 9440 topic_id: 22825 reply_id: 91208[/import]

Documentation is the bane of my existence, a necessary evil I guess :slight_smile:

There is a possibility you will need to either convert the position you get to a world position or do something like this:

map:slideToPosition(mapx + display.contentWidth / 2, mapy + display.contentHeight / 2, 2000) [import]uid: 119420 topic_id: 22825 reply_id: 91240[/import]