How to reload current scene?

Hi I am building an game where I need to reload the current scene.I have tried this code but it says something string to find (not sure what that exactly says.) I have attached a screen shot of it.

 local composer = require( “composer” )

– Later…
local currScene = composer.getSceneName( “nameofscene” )
composer.gotoScene( currScene

When you’re in main.lua you don’t have a scene yet, so calling:

local currScene = composer.getSceneName( "nameofscene" )

doesn’t do any thing. You simply need to do:

composer.gotoScene("level1")

Now if level1.lua has errors it can generate similar errors.

Rob

In your case, it should be quite simple:

Try this:

composer.removeScene("level1")--or ("main") in your case 

Then:

composer.gotoScene("main")

Try that, I believe it should restart the entire scene from new.

I meant: composer.removeScene(“level1”), composer.gotoScene(“level1”)

You should just reset every thing manually. It is much faster to move things back with a custom function that resets everything vs the slow way of deleting everything from memory and reloading images.

Thanks everybody! It worked! Great Corona, Great people.  :smiley:

When you’re in main.lua you don’t have a scene yet, so calling:

local currScene = composer.getSceneName( "nameofscene" )

doesn’t do any thing. You simply need to do:

composer.gotoScene("level1")

Now if level1.lua has errors it can generate similar errors.

Rob

In your case, it should be quite simple:

Try this:

composer.removeScene("level1")--or ("main") in your case 

Then:

composer.gotoScene("main")

Try that, I believe it should restart the entire scene from new.

I meant: composer.removeScene(“level1”), composer.gotoScene(“level1”)

You should just reset every thing manually. It is much faster to move things back with a custom function that resets everything vs the slow way of deleting everything from memory and reloading images.

Thanks everybody! It worked! Great Corona, Great people.  :smiley: