Lime Tutorial 13 Moving a Map Not Working

I’ve been playing around with Tutorial 13 and I just can’t get it to work.  I have tried using the version of Lime you can download from here:

https://github.com/OutlawGameTools/Lime2DTileEngine/zipball/master

and the one you can download from here:

https://github.com/OutlawGameTools/Lime2DTileEngine/archive/master.zip

They both seem to be Lime Version 3.5

This is the code from the tutorial page that just won’t work:

[lua]lime = require(“lime.lime”)

local map = lime.loadMap(“tutorial20.tmx”)
local physical = lime.buildPhysical(map)
local visual = lime.createVisual(map)

local onTap = function(event)
local screenPosition = { x = event.x, y = event.y }
local worldPosition = lime.utils.screenToWorldPosition(map, screenPosition)
– Instantly jump to the new position
map:setPosition(worldPosition.x, worldPosition.y)
– Fade out, set position and then fade back in again
– map:fadeToPosition(worldPosition.x, worldPosition.y, 1000)
– Slide to the new position
– map:slideToPosition(worldPosition.x, worldPosition.y, 2000)
end
Runtime:addEventListener(“tap”, onTap)[/lua]

I’ve attached a screenshot of the error I get.  The indication of a problem occurs here:

[lua]

function Utils:screenToWorldPosition(map, position)

    local _map = map

    local _position = position

    

    local newPosition = {}

    

    if _map.world then

[/lua]

And it appears that _map.world is nil.   I’ve tried to print out map by converting it from a table into a series of formatted strings and it doesn’t seem like there is a “world” attribute anywhere in it.   I could use a fresh set of eyes or a more experienced opinion on this one.  

By the way, the touch part of the tutorial works fine:

[lua]

local onTouch = function(event)

    map:drag(event)

end

Runtime:addEventListener(“touch”, onTouch)

[/lua]

Hi Michael

I had the same problem. I fix it changing this line

local worldPosition = lime.utils.screenToWorldPosition(map, screenPosition)

to local worldPosition = lime.utils:screenToWorldPosition(map, screenPosition).

But my problem is the mp does’nt load correctly. If I drag the map It doesn’t show the next Tiles of the map. It only shows the blue backgroud.

Yo have the same problem?

marktamanosantos I love you!   I spent hours and days working on this thing.  Your fix worked like a charm.  Unfortunately, I am not sure why you are having the problem with the blue background.  You might want to try a different map, maybe one that’s smaller and simpler?   When I try to drag the map from tutorial 20, it works fine for me.   Let me know if there is something you’d like me to try.

By the way, the touch part of the tutorial works fine:

[lua]

local onTouch = function(event)

    map:drag(event)

end

Runtime:addEventListener(“touch”, onTouch)

[/lua]

Hi Michael

I had the same problem. I fix it changing this line

local worldPosition = lime.utils.screenToWorldPosition(map, screenPosition)

to local worldPosition = lime.utils:screenToWorldPosition(map, screenPosition).

But my problem is the mp does’nt load correctly. If I drag the map It doesn’t show the next Tiles of the map. It only shows the blue backgroud.

Yo have the same problem?

marktamanosantos I love you!   I spent hours and days working on this thing.  Your fix worked like a charm.  Unfortunately, I am not sure why you are having the problem with the blue background.  You might want to try a different map, maybe one that’s smaller and simpler?   When I try to drag the map from tutorial 20, it works fine for me.   Let me know if there is something you’d like me to try.