Why am i getting this error pt. 2

I am trying to add a feature that my play button takes me to my game.lua file . With the help of some people I solved one of my errors . But sadly I have another that I don’t know how to fix .here is my error and code .

Error :

Windows simulator build date: Nov 18 2014 @ 18:35:32

Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2014.2511
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device

Copyright © 2009-2014  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2014.2511
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2014.2511
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device
Runtime error
c:\users\true\documents\corona projects\bouncy balls\menu.lua:4: attempt to inde
x global ‘booton’ (a nil value)
stack traceback:
        [C]: in function ‘error’
        ?: in function ‘gotoScene’
        c:\users\true\documents\corona projects\bouncy balls\main.lua:16: in main chunk

Main.lua code:

----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local widget = require( "widget" ) local ads = require( "ads" ) local myData = require( "mydata" ) local gameNetwork = require("gameNetwork") local device = require( "device" ) display.setStatusBar( display.HiddenStatusBar ) storyboard.gotoScene( "menu" )

Menu.lua code:

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() function booton:touch(event) if event.phase == "began" then elseif event.phase == "ended" then storyboard.gotoScene("level1", "fade", 500) end return true end function scene:createScene( event ) local group = self.view -- display background image local background = display.newImage( "background.png" ) background.x = 10; background.y = 308 -- display ground image local ground = display.newImage( "ground.png" ) ground.x = 145; ground.y = 480 -- display play button local button = display.newImageRect( "button.png", 100, 80 ) button.x = 160 button.y = 300 -- display logo image local logo = display.newImageRect( "logo.png", 300, 200 ) logo.x = 160 logo.y = 20 local booton = display.newImage( "booton.png" ) booton.x = 160 booton.y = 400 group:insert( background ) group:insert( ground ) group:insert( button ) group:insert( logo ) group:insert(booton) 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 booton:addEventListener("touch", booton) scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene 

level1.lua code:

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() function scene:createScene( event ) local group = self.view local physics = require( "physics" ) physics.start() physics.setGravity(0, 7) -- display background image local background = display.newImage( "background.png" ) background.x = 10; background.y = 308 -- display ground image local ground = display.newImage( "ground.png" ) ground.x = 145; ground.y = 480 physics.addBody( ground, "static" , { friction=0.5, bounce=0.1 } ) -- create object local myObject = display.newRect( 0, 0, 100, 30 ) myObject:setFillColor( 0 ) myObject.x = 145; myObject.y = 400 physics.addBody( myObject, "kinematic" , { myObject, friction=0.5, bounce=1 } ) -- touch listener function function myObject:touch( event ) if event.phase == "moved" then self.x = event.x self.y = event.y end return true end -- make 'myObject' listen for touch events myObject:addEventListener( "touch", myObject ) -- display ball image local ball = display.newImageRect( "ball.png", 81, 60 ) ball.x, ball.y = 145, 200 ball.rotation = .5 -- add physics to the ball physics.addBody( ball, { "dynamic" ,density=1000, friction=0.3, bounce=0.1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 387 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 300 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 202 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 104 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 7 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = 50, -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = 135, -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 232 wall.y = -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 335 wall.y = -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 3 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 98 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 325 wall.y = 195 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 292 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 387 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=4 } ) group:insert(background) group:insert(ground) group:insert(myObject) group:insert(ball) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) 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 ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

Why am I getting this error. Also what do I need to add .\

Thank you.

I answered this on your other thread.  I didn’t factor in that you’re using an object touch handler, not a function touch handler.  You have to move your booton:touch() function inside your createScene() function right after you define booton.

Rob

I answered this on your other thread.  I didn’t factor in that you’re using an object touch handler, not a function touch handler.  You have to move your booton:touch() function inside your createScene() function right after you define booton.

Rob