gridToWorldPosition problem

I'm trying to use gridToWorldPosition but get error:

"attempt to call field 'gridToWorldPosition' (a nil value)"

Scanning through all the lime lua modules the only place I can see this function is where it is called by createTileAt in lime-tileLayer.lua but it doesn't seem to be defined anywhere.

What I'm trying to do is convert an x, y into a gridPosition and then turn that gridPosition back into an x,y. The idea being that I start with an x,y that is at a random place within a grid position but I want an x,y that is in the correct place within the grid such that I can place a tile.sprite using this new x,y and the tile will then be placed correctly in the grid.

1
2
3
4
5
-- get grid position from x, y
local gridPosition = lime.utils.worldToGridPosition(map, {x=event.x, y=event.y})
 
-- convert gridPosition to worldPosition
local worldPosition = lime.utils.gridToWorldPosition( map, gridPosition, {x=0, y=32})

Is this an Iso or Orthographic map? And what version of Lime are you using, there is a possibility the name of the function changed in an update but can't remember now.

Hi Graham,

It's an orthographic using Lime_3_3_May_2011.

Hmm, strange. Are you able to send your project, or a simple one demoing the problem, to support@justaddli.me for me to look at?

views:1527 update:2011/10/13 16:30:09
corona forums © 2003-2011