Composer Conundrum

i have a simple level select system but im stuck on how to implement a restart button, i had something like this but it shows me a black screen. You press the restart button on level 1 say for example and it takes you to restart.lua

-- restart.lua   local composer = require "composer" local scene = composer.newScene() composer.gotoScene( composer.getSceneName( "previous" ) ) return scene

this doesn’t work unfortunately, any ideas?

Hello again. I answered a bit ago and then deleted it.  Here is a tighter answer with an example.

Here is an empty example showing the “previous” scene code working.  Please give it a try on your copy of Corona and verify it works for you.  Then you might want to check your scene creation/destruction code for the cause of that black screen.

https://www.youtube.com/watch?v=-Mm772ZdQwg&feature=youtu.be&hd=1

I hope this helps.

thanks for the write up ed! Ive fixed it now though, the problem was not the logic but the code in the scene itself, i was doing something that composer didnt like

Hello again. I answered a bit ago and then deleted it.  Here is a tighter answer with an example.

Here is an empty example showing the “previous” scene code working.  Please give it a try on your copy of Corona and verify it works for you.  Then you might want to check your scene creation/destruction code for the cause of that black screen.

https://www.youtube.com/watch?v=-Mm772ZdQwg&feature=youtu.be&hd=1

I hope this helps.

thanks for the write up ed! Ive fixed it now though, the problem was not the logic but the code in the scene itself, i was doing something that composer didnt like

Hi roaminggamer,

I have read your solution and i have a question 

In your example each scene is in fact a main.lua like.

I would like to have a gridGame on separated files like your scenes but keep the rules on the gridGame (my main.lua) on a last separated file.

Is it possible ?   

Below what i would like to do :

config.lua events.lua main.lua (all the rules and the behavior on my table "the gridGame") level01.lua (only the description of my table, my gridgame01) level02.lua (only the description of my table, my gridgame02) ...

What the good way to reproduce this ?

Thanks for your response if never

Hi roaminggamer,

I have read your solution and i have a question 

In your example each scene is in fact a main.lua like.

I would like to have a gridGame on separated files like your scenes but keep the rules on the gridGame (my main.lua) on a last separated file.

Is it possible ?   

Below what i would like to do :

config.lua events.lua main.lua (all the rules and the behavior on my table "the gridGame") level01.lua (only the description of my table, my gridgame01) level02.lua (only the description of my table, my gridgame02) ...

What the good way to reproduce this ?

Thanks for your response if never