How to make a Game Menu using story boards?

Hi I’m trying to make a start menu using sotryboards. My game consist of a main.lua, menu.lua and a level1.lua.

I have been trying for days to get the storyboards and functions to work. I have managed to get the main.lua to go to the menu.lua, but now I am trying to create a play button to tap on realease to the level1.lua using story boards.

I’m trying to implement widgets buttons for a play and options buttons. I’m a beginner, but have been following titorials to get started. I need a little help in getting this to work. Is my code outdated? What do I have to do to get to play button to work.

Here is my code



– menu.lua


local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

local mydata = require (“mydata”)

local widget = require “widget”

display.setStatusBar( display.HiddenStatusBar )

function scene:createScene( event )
  local group = self.view

Background01 = display.newImageRect(“Assets/WoodStartScreen.png”, 570 , 360 );
Background01.x = display.contentCenterX
Background01.y = display.contentCenterY
W = display.contentWidth
H = display.contentHeight

local function onPlayBtnRelease()
  storyboard.gotoScene( “level1”, “fade”, 500 )
  return true
 
 end
 
local playBtn = widget.newButton
{
  label=“Play Now”,
  onRelease = onPlayBtnRelease
}
 
playBtn.x = halfW
playBtn.y = halfH
group:insert( playBtn )

end

end

function scene:enterScene( event )

end

function scene:exitScene( event )

end

function scene:destroyScene( event )

end

scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )

return scene
 

I’m a newby myself but have gotten Composer (newer version of Storyboard) to work like you’re describing.

The gotoScene function in my menu.lua is located before function scene create:scene  and my widget (much like you have) stays where it is.

See if that works.

I’ve got a main.lua, menu.lua and 3 different levels and they all work well using that same order:  storyboard.gotoScene before _function scene create:scene  _and widgets all within create:scene (like you have above)

Also, since you’re new as well, you may want to just skip Storyboard and use Composer.  You can see it here and it’s just about the same in terms of what goes where just replace “storyboard” with “composer”:

http://coronalabs.com/blog/2014/01/21/introducing-the-composer-api-plus-tutorial/

Thanks for the advice. I’ll see if it works.

I’m a newby myself but have gotten Composer (newer version of Storyboard) to work like you’re describing.

The gotoScene function in my menu.lua is located before function scene create:scene  and my widget (much like you have) stays where it is.

See if that works.

I’ve got a main.lua, menu.lua and 3 different levels and they all work well using that same order:  storyboard.gotoScene before _function scene create:scene  _and widgets all within create:scene (like you have above)

Also, since you’re new as well, you may want to just skip Storyboard and use Composer.  You can see it here and it’s just about the same in terms of what goes where just replace “storyboard” with “composer”:

http://coronalabs.com/blog/2014/01/21/introducing-the-composer-api-plus-tutorial/

Thanks for the advice. I’ll see if it works.