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 [import]uid: 43345 topic_id: 14898 reply_id: 314898[/import]

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:

  
--- 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  
  

You should then call that function when you are changing scenes etc.

For the second issue about pausing during a transition, the problem with that is that currently there is no in-built support in Corona for pausing/resuming transitions. Work arounds have been created for this in things like Jon Beebes game class as well as the CrawlSpaceLib so you may wish to look into using something like that. I will try to get something supported properly in a later version. [import]uid: 5833 topic_id: 14898 reply_id: 55781[/import]

Hi All,

Can anybody please suggest me on how to use the following class with lime to be compatible with ‘map:slideToPosition()’ for pausing the transitions.

Pausable timers and transitions with speed adjustment

http://developer.anscamobile.com/code/pausable-timers-and-transitions-speed-adjustment

Thanks
Babu
[import]uid: 43345 topic_id: 14898 reply_id: 70314[/import]

Looks like you would need to require that Lib and then go through all the Lime code changing all transition.to and timer.performWithDelay calls to use the new pausable ones. [import]uid: 5833 topic_id: 14898 reply_id: 70353[/import]

Thanks Graham. I will try it. [import]uid: 43345 topic_id: 14898 reply_id: 70529[/import]