Most efficient way to restart level

Help! Im in a big time crunch and am having trouble getting my level restart to work properly.

I have tried the separate restart.lua file from this topic:
http://developer.anscamobile.com/forum/2011/02/20/how-can-i-resetrestart-lua-levelscene

but have had no luck with it working.

I have also tried this method with no luck either,
http://developer.anscamobile.com/forum/2011/01/30/how-replay-current-level

So tell me, how do you restart your levels? Could you give a complete example so this thread could become an absolute reference for future users.

Cheers!

I also think the problem with those other threads in helping answer this question is their vagueness..

@Evna

The way i handle this is as follows;

- on 'restart' button release; save to a file the level number or string you wish to load next, then change scene to a loadinglevel.lua
- in the loadinglevel.lua module, read from the file the next level number or string that you want to load next using a timer with some delay, then change scenes with the data you just read.

This way if you have a 'next' button also then you can save the next level number to the file and your loadinglevel.lua will switch to the proper scene correctly.

Let me know if you have any questions.

I also tried "resetting" the values and ended up with a lot of problems. I had thought of doing exactly what Matt describes here but never put it into code yet. I'm glad that this is confirmed as a viable option. Thanks Matt and Evna.

views:1642 update:2011/10/13 9:25:17
corona forums © 2003-2011