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! [import]uid: 10355 topic_id: 8049 reply_id: 308049[/import]

I also think the problem with those other threads in helping answer this question is their vagueness… [import]uid: 10355 topic_id: 8049 reply_id: 28657[/import]

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

[import]uid: 20503 topic_id: 8049 reply_id: 28790[/import]

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. [import]uid: 31262 topic_id: 8049 reply_id: 30315[/import]