Storyboard Not Working

My buttons are not working for my storyboard. I have verified that all of the files work independently. Below is an extract from my coding that shows the button and the function that runs the storyboard. Could you help me with this problem? Thank you.

local startGameBtn

local function onStartGameBtnRelease( event )
    storyboard.gotoScene( “startgame”)
    return true
end

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

    startGameBtn = widget.newButton{
        label=“start game”,
        labelColor = { default={40}, over={100} },
        default=“paint.png”,
        over=“paint.png”,
        width=100, height=40,
        onRelease = onStartGameBtnRelease}

end

Can you be more specific on what you mean by “it doesn’t work”?  Are you getting any errors in your console log?  Is the button not doing anything?  Have you put any prints in the onStartGameBtnRelease() function to make sure you’re getting there?  Have you put any prints n the startgame.lua scene to make sure it’s createScene and enterScene functions are firing?

I really appreciate you taking the time to answer. I do not get any errors; however, the buttons don’t respond when I click on them.  In other words, the buttons do not take me to the next part of the storyboard. Below, I have copied the entire code for this file.

This is my first time coding in lua and I truly appreciate your help.

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

local widget = require “widget”

local startGameBtn

local function onStartGameBtnRelease( self, event )
    

    storyboard.gotoScene( “startgame”)
    
    return true
end

local characterBtn

local function onCharacterBtnRelease( self, event )
        
        storyboard.gotoScene(“character”, “fade”, 500)

        return true
end

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

    sakura = display.newImageRect( “sakura.png”, display.contentWidth, display.contentHeight )
    sakura:setReferencePoint( display.TopLeftReferencePoint )
    sakura.x, sakura.y = 0, 0
    
    
    titleLogo = display.newImageRect( “raindrop.png”, 300, 300 )
    titleLogo:setReferencePoint( display.CenterReferencePoint )
    titleLogo.x = 117
    titleLogo.y = 83

    
    startGameBtn = widget.newButton{
        label=“start game”,
        labelColor = { default={40}, over={100} },
        default=“paint.png”,
        over=“paint.png”,
        width=100, height=40,
        onRelease = onStartGameBtnRelease}    

            startGameBtn.view:setReferencePoint( display.CenterReferencePoint )
    startGameBtn.view.x = 88
    startGameBtn.view.y = 300

    characterBtn = widget.newButton{
        label=“characters”,
        labelColor = { default={40}, over={100} },
        default=“paint.png”,
        over=“paint.png”,
        width=100, height=40,
        onRelease = onCharacterBtnRelease}

            characterBtn.view:setReferencePoint( display.CenterReferencePoint )
    characterBtn.view.x = 85
    characterBtn.view.y = 275
    
    
    group:insert( background )
    group:insert( titleLogo )
    group:insert( startGameBtn.view )
    group:insert( characterBtn.view )
        
end

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

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

function scene:destroyScene( event )
    local group = self.view
    
    if startGameBtn then
        startGameBtn:removeSelf()
        startGameBtn = nil
    end
end

scene:addEventListener( “createScene”, scene )

scene:addEventListener( “enterScene”, scene )

scene:addEventListener( “exitScene”, scene )

scene:addEventListener( “destroyScene”, scene )

return scene

I would suggest putting some print statements in your button event handlers.  I don’t believe you need the “self” in the parameter list for those, but the way you have them written, it’s not causing any harm.  If you ever decide to access the event table, you will run into issues.

Let’s put some prints in and make sure you’re getting to those functions.

Also, these:

    group:insert( startGameBtn.view )
    group:insert( characterBtn.view )

probably should be:

    group:insert( startGameBtn )
    group:insert( characterBtn)

and things like:
 

    characterBtn.view.x = 85
    characterBtn.view.y = 275

should probably be:

    characterBtn.x = 85
    characterBtn.y = 275

Unless you are running a reallllllllly old version of Widgets.

Rob

Can you be more specific on what you mean by “it doesn’t work”?  Are you getting any errors in your console log?  Is the button not doing anything?  Have you put any prints in the onStartGameBtnRelease() function to make sure you’re getting there?  Have you put any prints n the startgame.lua scene to make sure it’s createScene and enterScene functions are firing?

I really appreciate you taking the time to answer. I do not get any errors; however, the buttons don’t respond when I click on them.  In other words, the buttons do not take me to the next part of the storyboard. Below, I have copied the entire code for this file.

This is my first time coding in lua and I truly appreciate your help.

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

local widget = require “widget”

local startGameBtn

local function onStartGameBtnRelease( self, event )
    

    storyboard.gotoScene( “startgame”)
    
    return true
end

local characterBtn

local function onCharacterBtnRelease( self, event )
        
        storyboard.gotoScene(“character”, “fade”, 500)

        return true
end

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

    sakura = display.newImageRect( “sakura.png”, display.contentWidth, display.contentHeight )
    sakura:setReferencePoint( display.TopLeftReferencePoint )
    sakura.x, sakura.y = 0, 0
    
    
    titleLogo = display.newImageRect( “raindrop.png”, 300, 300 )
    titleLogo:setReferencePoint( display.CenterReferencePoint )
    titleLogo.x = 117
    titleLogo.y = 83

    
    startGameBtn = widget.newButton{
        label=“start game”,
        labelColor = { default={40}, over={100} },
        default=“paint.png”,
        over=“paint.png”,
        width=100, height=40,
        onRelease = onStartGameBtnRelease}    

            startGameBtn.view:setReferencePoint( display.CenterReferencePoint )
    startGameBtn.view.x = 88
    startGameBtn.view.y = 300

    characterBtn = widget.newButton{
        label=“characters”,
        labelColor = { default={40}, over={100} },
        default=“paint.png”,
        over=“paint.png”,
        width=100, height=40,
        onRelease = onCharacterBtnRelease}

            characterBtn.view:setReferencePoint( display.CenterReferencePoint )
    characterBtn.view.x = 85
    characterBtn.view.y = 275
    
    
    group:insert( background )
    group:insert( titleLogo )
    group:insert( startGameBtn.view )
    group:insert( characterBtn.view )
        
end

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

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

function scene:destroyScene( event )
    local group = self.view
    
    if startGameBtn then
        startGameBtn:removeSelf()
        startGameBtn = nil
    end
end

scene:addEventListener( “createScene”, scene )

scene:addEventListener( “enterScene”, scene )

scene:addEventListener( “exitScene”, scene )

scene:addEventListener( “destroyScene”, scene )

return scene

I would suggest putting some print statements in your button event handlers.  I don’t believe you need the “self” in the parameter list for those, but the way you have them written, it’s not causing any harm.  If you ever decide to access the event table, you will run into issues.

Let’s put some prints in and make sure you’re getting to those functions.

Also, these:

    group:insert( startGameBtn.view )
    group:insert( characterBtn.view )

probably should be:

    group:insert( startGameBtn )
    group:insert( characterBtn)

and things like:
 

    characterBtn.view.x = 85
    characterBtn.view.y = 275

should probably be:

    characterBtn.x = 85
    characterBtn.y = 275

Unless you are running a reallllllllly old version of Widgets.

Rob