reloading storyboard problems

local storyboard = require(“storyboard”)

local scene = storyboard.newScene() 

local function goback(event)

storyboard.gotoScene(“scene1”)

end 

local startup = display.newText(“CLICK ANYWHERE TO START”, 0, 0, native.systemFontBold,20)

local warning = display.newText("DONT FORGET THE NARWHALS A RAGING DIABETIC ", 0, 0, native.systemFontBold,20)

startup.x = display.viewableContentWidth /2

startup.y = display.viewableContentHeight  / 2 

warning.x = (display.viewableContentWidth /2) 

warning.y = (display.viewableContentHeight  / 2) + 50 

Runtime:addEventListener(“touch”, goback)

return scene  

can someone tell me why this code will not go back to scene1 when i touch (quick reminder I am very new so I am not fully aware of the ins  and outs of story board)

Firstly you need to check the code in scene1 to make sure there are no errors there - otherwise the scene will not load.

You also need to check the event.phase in your goback function, otherwise this code will fire at least twice and cause an error (once when you press the button, another when you release, and possibly more if you move your finger across the button). It’s probably a good idea to prevent the user from clicking the button twice…

[lua]

local allowTouch = true  —put this at top of .lua file

–within goback

if event.phase == “ended” and allowTouch then

 allowTouch = false

 storyboard.gotoScene(“scene1”)

end

[/lua]

Finally is this the complete code? If so you are missing all the scene functions which storyboard needs to run correctly.

Storyboard has now been replaced by Composer, which is pretty much the same.

https://coronalabs.com/blog/2014/06/03/tutorial-understanding-the-composer-api/

Firstly you need to check the code in scene1 to make sure there are no errors there - otherwise the scene will not load.

You also need to check the event.phase in your goback function, otherwise this code will fire at least twice and cause an error (once when you press the button, another when you release, and possibly more if you move your finger across the button). It’s probably a good idea to prevent the user from clicking the button twice…

[lua]

local allowTouch = true  —put this at top of .lua file

–within goback

if event.phase == “ended” and allowTouch then

 allowTouch = false

 storyboard.gotoScene(“scene1”)

end

[/lua]

Finally is this the complete code? If so you are missing all the scene functions which storyboard needs to run correctly.

Storyboard has now been replaced by Composer, which is pretty much the same.

https://coronalabs.com/blog/2014/06/03/tutorial-understanding-the-composer-api/