Help with storyboard! Runtime error

I made a game for my son that works and I want to take it a bit further so I am trying to get it to work with storyboard so I can add other levels. This is the first program I’ve ever written so I’m new to this (but love it).
The game is simple- letters of the alphabet bounce around the screen and when a letter is touched audio plays the letter name and it disappears. I decided to try and get storyboard to work with just two letters first. I have main.lua, menu.lua and game.lua. The menu launches fine but when I touch the play button object I get the following error: ?:0: attempt to call method ‘getOrCreateTable’ (a nil value)

I tested the play buttons gotoScene with a very simple test.lua file that just changes the background and it worked so I’m pretty sure it’s an issue with my game.lua scene but I can’t figure out the problem. The game and menu scene code is below and I would appreciate any help/advice:

Game.lua:
[lua]local storyboard = require “storyboard”

local scene = storyboard.newScene()

local physics = require(“physics”);

local gameTimer;

local Random = math.random;

function scene:createScene(event)

    local group = self.view

   

    local background = display.newImage(“images/clouds.png”);

    group:insert(background)

    

– Load audio files    

    local music = audio.loadStream(“sounds/music.mp3”);

    group:insert(music)

    local voicea = audio.loadSound(“sounds/a.wav”);

    group:insert(voicea)

    local voiceb = audio.loadSound(“sounds/b.wav”);

    group:insert(voiceb)

    local alphabet = 2;

    group:insert(alphabet)

–Game over sequence- when no more letters exist then game over

        local function gameOver(condition)

            if (condition == “winner”) then

                    storyboard.gotoScene(“menu”, “fade”, 200)

            end

        end

– Letters removed after touched

        local function removeLettera(obj)

            obj:removeSelf();

            --lettera = lettera - 1;

            alphabet = alphabet - 1;

                if (alphabet == 0) then

                    gameOver(“winner”)

                end

        end

        local function removeLetterb(obj)

            obj:removeSelf();

            --letterb = letterb - 1;

            alphabet = alphabet - 1;

                if (alphabet == 0) then

                    gameOver(“winner”)

                end

        end

– 2. Set gravity to be inverted

    physics.start()

    physics.setGravity(0, -0.7)

    physics.setDrawMode(“normal”)

–Create boundries to keep letters from floating away

    local leftWall = display.newRect (0, 0, 1, display.contentHeight);

    local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight);

    local ceiling = display.newRect (0, 0, display.contentWidth, 1);

    local ground = display.newRect (0, display.contentHeight, display.contentWidth, 1);

    physics.addBody (leftWall, “static”,  { bounce = 0.2 } );

    physics.addBody (rightWall, “static”, { bounce = 0.3 } );

    physics.addBody (ceiling, “static”,   { bounce = 1 } );

    physics.addBody (ground, “static”,   { bounce = 0.1 } );

    group:insert(leftWall)

    group:insert(rightWall)

    group:insert(ceiling)

    group:insert(ground)

–Start of game

            local function startGame()

                – 3. Create a letters

                myLettera = display.newImageRect(“images/LetterA.jpg”, 50, 50);

                myLetterb = display.newImageRect(“images/LetterB.jpg”, 50, 50);

                myLettera:setReferencePoint(display.CenterReferencePoint);

                myLetterb:setReferencePoint(display.CenterReferencePoint);

                myLettera.x = Random(50, _W-50);

                myLetterb.x = Random(50, _W-50);

                myLettera.y = (_H-80);

                myLetterb.y = (_H-10);

                physics.addBody(myLettera, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=20});

                physics.addBody(myLetterb, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=20});

                group:insert(myLettera)

                group:insert(myLetterb)

–Touch functions for letters

                function myLettera:touch(e)

                        if (e.phase == “ended”) then

                            audio.play(voicea);

                            removeLettera(self);

                        end

                end

                function myLetterb:touch(e)

                        if (e.phase == “ended”) then

                            audio.play(voiceb);

                            removeLetterb(self);

                        end

                end

                myLettera:addEventListener(“touch”, myLettera);

                myLetterb:addEventListener(“touch”, myLetterb);

            end

    gameTimer = timer.performWithDelay(20, startGame());

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

end        

        

scene.addEventListener(“createScene”)

scene.addEventListener(“enterScene”)

scene.addEventListener(“exitScene”)

scene.addEventListener(“destroyScene”)

return scene[/lua]

Menu.lua:
[lua]

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

function scene:createScene(event)
local group = self.view
local background = display.newImage(“images/clouds.png”);
group:insert(background);

local function onPress()
storyboard.gotoScene(“game”, “fade”, 200)
return true;
end

local playBtn = widget.newButton{
label=“Play Now”,
onRelease = onPress
}
playBtn.x = _W /2
playBtn.y = _H - 80
group:insert( playBtn )

end

function scene:enterScene(event)
local group = self.view
if(storyboard.getPrevious() ~= nil) then
storyboard.purgeScene(storyboard.getPrevious())
storyboard.removeScene(storyboard.getPrevious())
end
end
function scene:exitScene(event)
local group = self.view
end
function scene:destroyScene(event)
local group = self.view
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene)
scene:addEventListener( “destroyScene”, scene )
return scene [/lua]

There is neither a startButton nor a getOrCreateTable variable in the code you provided. Are you sure this is the full code? Can you find the getOrCreateTable variable in any other lua files for this project? That would be the best place to start looking for the cause of this error.

I think it’s because you’re inserting sounds and the math.random function into group. Only display objects should be inserted. Sounds and functions can be stored in local variables and will be cleaned up by storyboard automatically.

I’ve reorganised your code a bit, obviously I can’t test it without the images but it should make things a bit clearer and more dynamic - it will be a lot easier to add further letters for example.

[lua]

local storyboard = require"storyboard"

local scene = storyboard.newScene()

local physics = require(“physics”);

local gameTimer;

local myLetters = {}

local group = display.newGroup()

local music = audio.loadStream(“sounds/music.mp3”);

local voicea = audio.loadSound(“sounds/a.wav”);

local voiceb = audio.loadSound(“sounds/b.wav”);

local alphabet = 2

local function gameOver(condition)

    – If the player pops all of the letters they win

    if (condition == “winner”) then

        storyboard.gotoScene(“menu”, “fade”, 200)

    end

end

local function touchLetter(e)

    local obj = e.target

    local snd = “voice” … obj.sound

    if (e.phase == “ended”) then

        audio.play(snd);

        display.remove(obj);

        alphabet = alphabet - 1

        if (alphabet == 0) then

          gameOver(“winner”)

        end

    end

end

local function startGame()

    – 3. Create a letter

    local fn = { “A”, “B” }

    local Random = math.random

    local lo = { 80, 10 }

    for a = 1, alphabet, 1 do

        local i = display.newImageRect(“images/Letter” … fn[a] … “.jpg”, 50, 50);

        i:setReferencePoint(display.CenterReferencePoint);

        i.x = Random(50, _W - 50);

        i.x = Random(50, _W - 50);

        i.y = (_H - 80);

        i.y = (_H - 10);

        physics.addBody(i, “dynamic”, { density = 0.1, friction = 0.0, bounce = 0.9, radius = 20 });

        physics.addBody(i, “dynamic”, { density = 0.1, friction = 0.0, bounce = 0.9, radius = 20 });

        group:insert(i)

        i:addEventListener(“touch”, touchLetter);

        i.sound = string.lower[fn[a]]

        myLetters[a] = i

    end

end

function scene:createScene(event)

    group = self.view

    local background = display.newImage(“images/clouds.png”);

    group:insert(background)

    local leftWall = display.newRect(0, 0, 1, display.contentHeight);

    local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight);

    local ceiling = display.newRect(0, 0, display.contentWidth, 1);

    local ground = display.newRect(0, display.contentHeight, display.contentWidth, 1);

    – Add physics to the walls. They will not move so they will be “static”

    physics.addBody(leftWall, “static”, { bounce = 0.2 });

    physics.addBody(rightWall, “static”, { bounce = 0.3 });

    physics.addBody(ceiling, “static”, { bounce = 1 });

    physics.addBody(ground, “static”, { bounce = 0.1 });

    group:insert(leftWall)

    group:insert(rightWall)

    group:insert(ceiling)

    group:insert(ground)

    timer.performWithDelay(20, startGame)

end

function scene:enterScene(event)

    local group = self.view

    – 2. Set gravity to be inverted

    physics.start()

    physics.setGravity(0, -0.7)

    physics.setDrawMode(“normal”)

end

function scene:exitScene(event)

    local group = self.view

end

function scene:destroyScene(event)

    local group = self.view

end

scene.addEventListener(“createScene”)

scene.addEventListener(“enterScene”)

scene.addEventListener(“exitScene”)

scene.addEventListener(“destroyScene”)

return scene

[/lua]

Sorry, I meant to say play button- its the widget on the menu scene. I have no getOrCreateTable variable, I believe it is part of storyboard. The first scene is menu.lua and I’m certain that the code in it works fine because I tested it with a different scene. In the menu’s onPress() function, I changed it to:

local function onPress() 

storyboard.gotoScene(“test”, “fade”, 200)            —changed “game” to “test”

return true

The “test” scene was test.lua, all it does is change the background image and it worked fine. After pressing the playbutton the scene chamged with no errors.

This is the full code, the only thing I didn’t post was the main.lua file which is only a few lines long but I’ll post it below.

Main.lua:

[lua]

display.setStatusBar(display.HiddenStatusBar);

_H = display.contentHeight;

_W = display.contentWidth;

local storyboard = require “storyboard”;

local physics = require(“physics”);

physics.setDrawMode(“normal”)

system.activate(“multitouch”)

storyboard.gotoScene( “menu” )

[/lua]

It’s crashing because it tries to load and run game.lua, but this has the errors in I mentioned above - trying to insert non-display objects into a display group.

I tried your code and then modified my code(posted below) with your suggestions but both give the same error. My original code, your code and my modified code all give this error:

Your code is much easier to work with and I really appreciate the time you took to re-write it. I wanted to write this game in that fashion but didn’t know how since this is my first step into programming.  

[lua]

local storyboard = require “storyboard”

local scene = storyboard.newScene()

local physics = require(“physics”);

function scene:createScene(event)

    local group = self.view

    local Random = math.random;

    local background = display.newImage(“images/clouds.png”);

    group:insert(background)

– Load audio

    local music = audio.loadStream(“sounds/music.mp3”);

    local voicea = audio.loadSound(“sounds/a.wav”);

    local voiceb = audio.loadSound(“sounds/b.wav”);

    local alphabet = 2;

–Game Over sequence- when no more letters exist then game over

        local function gameOver(condition)

            if (condition == “winner”) then

                    storyboard.gotoScene(“menu”, “fade”, 200)

            end

        end

– Letters removed after touched

        local function removeLettera(obj)

            obj:removeSelf();

            alphabet = alphabet - 1;

                if (alphabet == 0) then

                    gameOver(“winner”)

                end

        end

        local function removeLetterb(obj)

            obj:removeSelf();

              alphabet = alphabet - 1;

                if (alphabet == 0) then

                    gameOver(“winner”)

                end

        end

    – Create boundaries so letters wont float off-screen

    local leftWall = display.newRect (0, 0, 1, display.contentHeight);

    local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight);

    local ceiling = display.newRect (0, 0, display.contentWidth, 1);

    local ground = display.newRect (0, display.contentHeight, display.contentWidth, 1);

    physics.addBody (leftWall, “static”,  { bounce = 0.2 } );

    physics.addBody (rightWall, “static”, { bounce = 0.3 } );

    physics.addBody (ceiling, “static”,   { bounce = 1 } );

    physics.addBody (ground, “static”,   { bounce = 0.1 } );

    group:insert(leftWall)

    group:insert(rightWall)

    group:insert(ceiling)

    group:insert(ground)

    – Start of game

            local function startGame()

                – 3. Create a letters

                myLettera = display.newImageRect(“images/LetterA.jpg”, 50, 50);

                myLetterb = display.newImageRect(“images/LetterB.jpg”, 50, 50);

                myLettera:setReferencePoint(display.CenterReferencePoint);

                myLetterb:setReferencePoint(display.CenterReferencePoint);

                myLettera.x = Random(50, _W-50);

                myLetterb.x = Random(50, _W-50);

                myLettera.y = (_H-80);

                myLetterb.y = (_H-10);

                physics.addBody(myLettera, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=20});

                physics.addBody(myLetterb, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=20});

                group:insert(myLettera)

                group:insert(myLetterb)

– Touch functions for letters

                function myLettera:touch(e)

                        if (e.phase == “ended”) then

                            audio.play(voicea);

                            removeLettera(self);

                        end

                end

                function myLetterb:touch(e)

                        if (e.phase == “ended”) then

                            audio.play(voiceb);

                            removeLetterb(self);

                        end

                end

                myLettera:addEventListener(“touch”, myLettera);

                myLetterb:addEventListener(“touch”, myLetterb);

            end

    gameTimer = timer.performWithDelay(20, startGame());

end

function scene:enterScene(event)

    local group = self.view

    physics.start()

    physics.setGravity(0, -0.7)

    physics.setDrawMode(“normal”)

end

function scene:exitScene(event)

    local group = self.view

end

function scene:destroyScene(event)

    local group = self.view

end        

        

scene.addEventListener(“createScene”)

scene.addEventListener(“enterScene”)

scene.addEventListener(“exitScene”)

scene.addEventListener(“destroyScene”)

return scene

[/lua]

You might want to rename your scene transition event function in the menu.lua file. It appears you have it called onPress, which is already a pre-labeled event call for widgets. Change it to “PressPlay()”, check to make sure your game file is labelled “game.lua” (all lowercase) and let us know how you get on.

Just tried renaming the onPress function as you suggested and got the same error. I quadruple checked the file names and they are definitely right. I’m baffled by why this won’t work.

– I should note that I haven’t read all the posts –

I made a few changes to your menu.lua
Hope it helps.

local storyboard = require ("storyboard") local scene = storyboard.newScene() local widget = require "widget" -- Transitions to the 'game' scene when the play-button is pressed. function onPlayPress()     storyboard.gotoScene("game", "fade", 200)          return true; end --============================================================================== ------------------------------------------------------------------------------- function scene:createScene(event) local group = self.view     local background = display.newImage("images/clouds.png");               local playBtn = widget.newButton     {                label= "Play Now",     onRelease = onPlayPress     }          playBtn.x = \_W /2     playBtn.y = \_H - 80 -------------------------------------------------------------------------------     -- insert objects into display-group     group:insert( background );     group:insert( playBtn ) end --============================================================================== ----------------================SCENE MANAGEMENT=================--------------- -- Called immediately after scene has moved onscreen: function scene:enterScene(event)     local group = self.view          if(storyboard.getPrevious() ~= nil) then          storyboard.purgeScene(storyboard.getPrevious())     storyboard.removeScene(storyboard.getPrevious())          end end --Called when scene is about to move offscreen: function scene:exitScene(event)     local group = self.view end --If scene's view is removed, scene:destroyScene() will be called just prior to: function scene:destroyScene(event)     local group = self.view     if playBtn then         playBtn:removeSelf() -- widgets must be manually removed         playBtn = nil     end end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene) scene:addEventListener( "destroyScene", scene ) return scene  

-Saer

Edit: Mainly I just organized it a bit. Maybe it will help you figure out the problem.
idk. :slight_smile:

So I’ve tried all of the codes posted so far and variations of them and I keep getting the same error. I am stumped. I can’t figure out what is in the game.lua scene that is causing the problem.

Try adding some print statements throughout your code to try and get a better idea of what is causing the error.

-Saer

Yea man, you might want to start troubleshooting from the beginning. I use Storyboard in all my projects and I don’t have a problem. Start with just progressing from scene to scene (denoting movement by terminal print statements); then start adding display objects to the “group” display group/

There is neither a startButton nor a getOrCreateTable variable in the code you provided. Are you sure this is the full code? Can you find the getOrCreateTable variable in any other lua files for this project? That would be the best place to start looking for the cause of this error.

I think it’s because you’re inserting sounds and the math.random function into group. Only display objects should be inserted. Sounds and functions can be stored in local variables and will be cleaned up by storyboard automatically.

I’ve reorganised your code a bit, obviously I can’t test it without the images but it should make things a bit clearer and more dynamic - it will be a lot easier to add further letters for example.

[lua]

local storyboard = require"storyboard"

local scene = storyboard.newScene()

local physics = require(“physics”);

local gameTimer;

local myLetters = {}

local group = display.newGroup()

local music = audio.loadStream(“sounds/music.mp3”);

local voicea = audio.loadSound(“sounds/a.wav”);

local voiceb = audio.loadSound(“sounds/b.wav”);

local alphabet = 2

local function gameOver(condition)

    – If the player pops all of the letters they win

    if (condition == “winner”) then

        storyboard.gotoScene(“menu”, “fade”, 200)

    end

end

local function touchLetter(e)

    local obj = e.target

    local snd = “voice” … obj.sound

    if (e.phase == “ended”) then

        audio.play(snd);

        display.remove(obj);

        alphabet = alphabet - 1

        if (alphabet == 0) then

          gameOver(“winner”)

        end

    end

end

local function startGame()

    – 3. Create a letter

    local fn = { “A”, “B” }

    local Random = math.random

    local lo = { 80, 10 }

    for a = 1, alphabet, 1 do

        local i = display.newImageRect(“images/Letter” … fn[a] … “.jpg”, 50, 50);

        i:setReferencePoint(display.CenterReferencePoint);

        i.x = Random(50, _W - 50);

        i.x = Random(50, _W - 50);

        i.y = (_H - 80);

        i.y = (_H - 10);

        physics.addBody(i, “dynamic”, { density = 0.1, friction = 0.0, bounce = 0.9, radius = 20 });

        physics.addBody(i, “dynamic”, { density = 0.1, friction = 0.0, bounce = 0.9, radius = 20 });

        group:insert(i)

        i:addEventListener(“touch”, touchLetter);

        i.sound = string.lower[fn[a]]

        myLetters[a] = i

    end

end

function scene:createScene(event)

    group = self.view

    local background = display.newImage(“images/clouds.png”);

    group:insert(background)

    local leftWall = display.newRect(0, 0, 1, display.contentHeight);

    local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight);

    local ceiling = display.newRect(0, 0, display.contentWidth, 1);

    local ground = display.newRect(0, display.contentHeight, display.contentWidth, 1);

    – Add physics to the walls. They will not move so they will be “static”

    physics.addBody(leftWall, “static”, { bounce = 0.2 });

    physics.addBody(rightWall, “static”, { bounce = 0.3 });

    physics.addBody(ceiling, “static”, { bounce = 1 });

    physics.addBody(ground, “static”, { bounce = 0.1 });

    group:insert(leftWall)

    group:insert(rightWall)

    group:insert(ceiling)

    group:insert(ground)

    timer.performWithDelay(20, startGame)

end

function scene:enterScene(event)

    local group = self.view

    – 2. Set gravity to be inverted

    physics.start()

    physics.setGravity(0, -0.7)

    physics.setDrawMode(“normal”)

end

function scene:exitScene(event)

    local group = self.view

end

function scene:destroyScene(event)

    local group = self.view

end

scene.addEventListener(“createScene”)

scene.addEventListener(“enterScene”)

scene.addEventListener(“exitScene”)

scene.addEventListener(“destroyScene”)

return scene

[/lua]

Sorry, I meant to say play button- its the widget on the menu scene. I have no getOrCreateTable variable, I believe it is part of storyboard. The first scene is menu.lua and I’m certain that the code in it works fine because I tested it with a different scene. In the menu’s onPress() function, I changed it to:

local function onPress() 

storyboard.gotoScene(“test”, “fade”, 200)            —changed “game” to “test”

return true

The “test” scene was test.lua, all it does is change the background image and it worked fine. After pressing the playbutton the scene chamged with no errors.

This is the full code, the only thing I didn’t post was the main.lua file which is only a few lines long but I’ll post it below.

Main.lua:

[lua]

display.setStatusBar(display.HiddenStatusBar);

_H = display.contentHeight;

_W = display.contentWidth;

local storyboard = require “storyboard”;

local physics = require(“physics”);

physics.setDrawMode(“normal”)

system.activate(“multitouch”)

storyboard.gotoScene( “menu” )

[/lua]

It’s crashing because it tries to load and run game.lua, but this has the errors in I mentioned above - trying to insert non-display objects into a display group.

I tried your code and then modified my code(posted below) with your suggestions but both give the same error. My original code, your code and my modified code all give this error:

Your code is much easier to work with and I really appreciate the time you took to re-write it. I wanted to write this game in that fashion but didn’t know how since this is my first step into programming.  

[lua]

local storyboard = require “storyboard”

local scene = storyboard.newScene()

local physics = require(“physics”);

function scene:createScene(event)

    local group = self.view

    local Random = math.random;

    local background = display.newImage(“images/clouds.png”);

    group:insert(background)

– Load audio

    local music = audio.loadStream(“sounds/music.mp3”);

    local voicea = audio.loadSound(“sounds/a.wav”);

    local voiceb = audio.loadSound(“sounds/b.wav”);

    local alphabet = 2;

–Game Over sequence- when no more letters exist then game over

        local function gameOver(condition)

            if (condition == “winner”) then

                    storyboard.gotoScene(“menu”, “fade”, 200)

            end

        end

– Letters removed after touched

        local function removeLettera(obj)

            obj:removeSelf();

            alphabet = alphabet - 1;

                if (alphabet == 0) then

                    gameOver(“winner”)

                end

        end

        local function removeLetterb(obj)

            obj:removeSelf();

              alphabet = alphabet - 1;

                if (alphabet == 0) then

                    gameOver(“winner”)

                end

        end

    – Create boundaries so letters wont float off-screen

    local leftWall = display.newRect (0, 0, 1, display.contentHeight);

    local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight);

    local ceiling = display.newRect (0, 0, display.contentWidth, 1);

    local ground = display.newRect (0, display.contentHeight, display.contentWidth, 1);

    physics.addBody (leftWall, “static”,  { bounce = 0.2 } );

    physics.addBody (rightWall, “static”, { bounce = 0.3 } );

    physics.addBody (ceiling, “static”,   { bounce = 1 } );

    physics.addBody (ground, “static”,   { bounce = 0.1 } );

    group:insert(leftWall)

    group:insert(rightWall)

    group:insert(ceiling)

    group:insert(ground)

    – Start of game

            local function startGame()

                – 3. Create a letters

                myLettera = display.newImageRect(“images/LetterA.jpg”, 50, 50);

                myLetterb = display.newImageRect(“images/LetterB.jpg”, 50, 50);

                myLettera:setReferencePoint(display.CenterReferencePoint);

                myLetterb:setReferencePoint(display.CenterReferencePoint);

                myLettera.x = Random(50, _W-50);

                myLetterb.x = Random(50, _W-50);

                myLettera.y = (_H-80);

                myLetterb.y = (_H-10);

                physics.addBody(myLettera, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=20});

                physics.addBody(myLetterb, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=20});

                group:insert(myLettera)

                group:insert(myLetterb)

– Touch functions for letters

                function myLettera:touch(e)

                        if (e.phase == “ended”) then

                            audio.play(voicea);

                            removeLettera(self);

                        end

                end

                function myLetterb:touch(e)

                        if (e.phase == “ended”) then

                            audio.play(voiceb);

                            removeLetterb(self);

                        end

                end

                myLettera:addEventListener(“touch”, myLettera);

                myLetterb:addEventListener(“touch”, myLetterb);

            end

    gameTimer = timer.performWithDelay(20, startGame());

end

function scene:enterScene(event)

    local group = self.view

    physics.start()

    physics.setGravity(0, -0.7)

    physics.setDrawMode(“normal”)

end

function scene:exitScene(event)

    local group = self.view

end

function scene:destroyScene(event)

    local group = self.view

end        

        

scene.addEventListener(“createScene”)

scene.addEventListener(“enterScene”)

scene.addEventListener(“exitScene”)

scene.addEventListener(“destroyScene”)

return scene

[/lua]

You might want to rename your scene transition event function in the menu.lua file. It appears you have it called onPress, which is already a pre-labeled event call for widgets. Change it to “PressPlay()”, check to make sure your game file is labelled “game.lua” (all lowercase) and let us know how you get on.

Just tried renaming the onPress function as you suggested and got the same error. I quadruple checked the file names and they are definitely right. I’m baffled by why this won’t work.

– I should note that I haven’t read all the posts –

I made a few changes to your menu.lua
Hope it helps.

local storyboard = require ("storyboard") local scene = storyboard.newScene() local widget = require "widget" -- Transitions to the 'game' scene when the play-button is pressed. function onPlayPress()     storyboard.gotoScene("game", "fade", 200)          return true; end --============================================================================== ------------------------------------------------------------------------------- function scene:createScene(event) local group = self.view     local background = display.newImage("images/clouds.png");               local playBtn = widget.newButton     {                label= "Play Now",     onRelease = onPlayPress     }          playBtn.x = \_W /2     playBtn.y = \_H - 80 -------------------------------------------------------------------------------     -- insert objects into display-group     group:insert( background );     group:insert( playBtn ) end --============================================================================== ----------------================SCENE MANAGEMENT=================--------------- -- Called immediately after scene has moved onscreen: function scene:enterScene(event)     local group = self.view          if(storyboard.getPrevious() ~= nil) then          storyboard.purgeScene(storyboard.getPrevious())     storyboard.removeScene(storyboard.getPrevious())          end end --Called when scene is about to move offscreen: function scene:exitScene(event)     local group = self.view end --If scene's view is removed, scene:destroyScene() will be called just prior to: function scene:destroyScene(event)     local group = self.view     if playBtn then         playBtn:removeSelf() -- widgets must be manually removed         playBtn = nil     end end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene) scene:addEventListener( "destroyScene", scene ) return scene  

-Saer

Edit: Mainly I just organized it a bit. Maybe it will help you figure out the problem.
idk. :slight_smile: