map:destroy()

I've been thinking of using the following method to switch between maps:

currentMap = 1

function loadMap()
map = lime.loadMap("map"..currentMap..".tmx")
end

if collectables == 10 then
map:destroy()
currentMap = (currentMap + 1)
loadMap()
end

...

map:destroy() gives me an error:

Runtime error
/Users/MerelFaber/Desktop/platform/lime-tile.lua:795: attempt to call method 'removeSelf' (a nil value)

which is the function Tile:destroy():
local visual = self:getVisual()

if visual then
visual:removeSelf()
visual = nil
end

Once I remove the destroy line it does load the new map... it just shows both the previous and the newest map. Using :hide() on the previous map isn't an option either, because the collision areas are still there.

any input on how to properly remove the map or any alternative for this system (I was hoping to avoid using director)?

The issue with the nil function has been fixed for the next version, it was meant to be fixed for 3.2 but somehow got missed. To fix it just open up "lime-tile.lua" and change:

1
visual:removeSelf()

Thanks for the extremely fast reply.

I changed the code and it works like a charm!

btw, is there a way to use transitions on layer?

for example:
transition.to(background,{time=2000,alpha=0}) or
transition.to(background.group,{time=2000,alpha=0})

currently I doing this manually using a lot of functions,background.group.alpha and timer.performWithDelay :)

double post

Each layer has a displayGroup which has all the tiles in, assuming "background" is a layer object then you can do a transition like so:

transition.to( background.group, { time=2000, alpha = 0 } )

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