Storyboard will not run when reentered - what is wrong with my code?

I see that storyboard is being replace with composer but I am creating this project for a class I am taking and storyboard is required. I start with main.lua, then start.lua (which has a play button to run through 4 seasons), spring.lua, summer.lua, autumn.lua, then winter.lua. That works fine, but I want to either go back to start so user can replay or to spring to repeat. I have changed the call in winter to go to main.lua , tried spring.lua, tried start;lua - all ends when spring.lua loads. I tap the screen and instead of moving to summer.lua like the first time through it stops. Below is the code from main.lua, start.lua, sping.lua, and winter.lua. (summer.lua and autumn.lua are the same as the others with different backgrounds.) I am new at this and cannot see my problem. Could someone point out my error please? Thank you in advance.

-- main.lua local storyboard = require "storyboard" -- Load the first scene to be shown storyboard.gotoScene( "start")

--------------------------------------------------------------------------------- -- -- start.lua -- --------------------------------------------------------------------------------- local storyboard = require "storyboard" local scene = storyboard.newScene() --------------------------------------------------------------------------------- -- BEGINNING OF YOUR SCENE --------------------------------------------------------------------------------- --Called if the scene hasn't been previously seen function scene:createScene( event ) local StartGroup = self.view imgSeasons = display.newImage("seasons.png", 0, 0) imgSeasons.x = display.contentWidth / 2 imgSeasons.y = display.contentHeight / 2 StartGroup:insert(imgSeasons) imgPlay = display.newImage("lilac\_play.png") imgPlay.x = display.contentWidth / 2 imgPlay.y = display.contentHeight / 2 + 200 StartGroup:insert(imgPlay) end function onBackgroundTouch() storyboard.gotoScene("spring", "fade", 400) end function scene:enterScene(event) imgPlay:addEventListener("touch", onBackgroundTouch) end function scene:exitScene(event) imgPlay:removeEventListener("touch", onBackgroundTouch) end function scene:destroyScene(event) end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

--------------------------------------------------------------------------------- -- -- spring.lua -- --------------------------------------------------------------------------------- local storyboard = require "storyboard" local scene = storyboard.newScene() --------------------------------------------------------------------------------- -- BEGINNING OF YOUR SCENE --------------------------------------------------------------------------------- --Called if the scene hasn't been previously seen function scene:createScene( event ) local SpringGroup = self.view backgroundImage = display.newImage("spring.png", 0, 0) backgroundImage.x = display.contentWidth/2 backgroundImage.y = display.contentHeight/2 SpringGroup:insert(backgroundImage) springText = display.newText("Spring",0 ,0, nil, 36) springText.x = display.contentWidth/2 springText.y = display.contentHeight/2 SpringGroup:insert(springText) end local function onBackgroundTouch() storyboard.gotoScene( "summer", {effect = "zoomInOut", time = 800 } ) end function scene:enterScene(event) backgroundImage:addEventListener("touch", onBackgroundTouch) end function scene:exitScene(event) backgroundImage:removeEventListener("touch", onBackgroundTouch) end function scene:destroyScene(event) end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

--------------------------------------------------------------------------------- -- -- winter.lua -- --------------------------------------------------------------------------------- local storyboard = require "storyboard" local scene = storyboard.newScene() --------------------------------------------------------------------------------- -- BEGINNING OF YOUR SCENE --------------------------------------------------------------------------------- --Called if the scene hasn't been previously seen function scene:createScene( event ) local WinterGroup = self.view backgroundImage = display.newImage("winter.png", 0, 0) backgroundImage.x = display.contentWidth/2 backgroundImage.y = display.contentHeight/2 WinterGroup:insert(backgroundImage) winterText = display.newText("Winter",0 ,0, nil, 36) winterText.x = display.contentWidth/2 winterText.y = display.contentHeight/2 WinterGroup:insert(winterText) end local function onBackgroundTouch() storyboard.gotoScene( "spring", {effect = "zoomInOut", time = 800 } ) end function scene:enterScene(event) backgroundImage:addEventListener("touch", onBackgroundTouch) end function scene:exitScene(event) backgroundImage:removeEventListener("touch", onBackgroundTouch) end function scene:destroyScene(event) end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

That’s a lot of code to post, sorry, I would appreciate the help.

A couple of things…

  1. You can specify group while making a display object, including text

[lua]local myImage = display.newImage(groupname, “filename.png”)[/lua]

  1. When making a touch event I would be careful to set the event phase. If you don’t, it’s entirely possible to, say, trigger a storyboard.gotoScene() command 2-3 times on a single press.

[lua]local function onBackgroundTouch(event)

  if event.phase == “ended” then

    – do stuff

  end

end[/lua]

  1. At a glance it’s difficult to say what’s wrong, so I strongly suggest adding a few print statements. You say that spring stops working (ie: nothing happens when you touch the image) so that’s a good place to start.

[lua]local function onBackgroundTouch(event)

  if event.phase == “ended” then

    print(“Touched background”)

    – do stuff

  end

end[/lua]

If you don’t see that statement in the console you know that something is not binding touch to the image.

Thank you for your tips, I will try them and hope the problem shows itself. I appreciate your response!

A couple of things…

  1. You can specify group while making a display object, including text

[lua]local myImage = display.newImage(groupname, “filename.png”)[/lua]

  1. When making a touch event I would be careful to set the event phase. If you don’t, it’s entirely possible to, say, trigger a storyboard.gotoScene() command 2-3 times on a single press.

[lua]local function onBackgroundTouch(event)

  if event.phase == “ended” then

    – do stuff

  end

end[/lua]

  1. At a glance it’s difficult to say what’s wrong, so I strongly suggest adding a few print statements. You say that spring stops working (ie: nothing happens when you touch the image) so that’s a good place to start.

[lua]local function onBackgroundTouch(event)

  if event.phase == “ended” then

    print(“Touched background”)

    – do stuff

  end

end[/lua]

If you don’t see that statement in the console you know that something is not binding touch to the image.

Thank you for your tips, I will try them and hope the problem shows itself. I appreciate your response!