control auto-scrolling ( pause and resume ) of a map in corona sdk using lime without memory leak

Hi all,

I am new to game development and I am using corona sdk with lime to develop one of our games. I am using director class to switch among the screens.

Our requirement is to auto scroll the map irrespective of the position of the player. I have used map:slideToPosition() method to achieve this. But is causing the memory leak when ever I want to switch among the screens in the middle of the scrolling transition.

Also I am unable to pause/resume the game properly in the middle of the scrolling.

Please suggest me a way to solve memory leak and low fps problem for this.

Thanks
Babu

For the first issue, try adding in this new function into "lime-map.lua", I haven't tested it yet though so if you could that would be great:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--- Cancels any slideTo/fadeTo transitions on the map. Should be called when destroying the map or changing Director scenes.
function Map:cancelTransitions()
        
        local visual = self:getVisual()
        
        if not visual then
                return
        end
        
        if visual.fadeTransition then
                transition.cancel( visual.fadeTransition )
                visual.moveDelayTimer = nil
        end
        
        if visual.slideTransition then
                transition.cancel( visual.slideTransition )
                visual.moveDelayTimer = nil
        end
        
        if visual.moveDelayTimer then
                timer.cancel( visual.moveDelayTimer )
                visual.moveDelayTimer = nil
        end
        
end
views:1344 update:2011/10/13 16:30:09
corona forums © 2003-2011