I'm making a game app in Corona SDK and I'm getting an error when I click my start button in my interface that is trying to load up my first scene.
Here are my codes:
main.lua
`local storyboard = require "storyboard"
storyboard.gotoScene("menu")`
menu.lua
`local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local widget = require( "widget" )`
`local background = display.newImage("Legend of Kael.jpg", true)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2`
`local roundedRect = display.newRoundedRect( 10, 50, 300, 40, 8 )
roundedRect.anchorX, roundedRect.anchorY = 0.0, 0.0
roundedRect:setFillColor( 0/255, 0/255, 0/255, 170/255 )`
`local function handleButtonEvent( event )
if ( "ended" == event.phase ) then
storyboard.gotoScene( "scene1", "crossFade", 400)
end
end`
`local button = widget.newButton
{
defaultFile = "buttonBlue.png",
overFile = "buttonBlueOver.png",
label = "Start Game",
emboss = true,
onEvent = handleButtonEvent,
}`
`button.x = 240; button.y = 200`
`function scene:createScene( event )
local group = self.view
end`
`function scene:enterScene( event )
storyboard.purgeScene("main")
local group = self.view
end`
`function scene:exitScene( event )
local group = self.view
storyboard.removeScene("main")
end`
`scene:addEventListener("createScene", scene)
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )`
`return scene`
scene1.lua
`local physics = require "physics"
physics.start()`
`local storyboard = require ("storyboard")
local scene = storyboard.newScene()`
`function scene:createScene(event)`
`local background = display.newImage("forest1.jpg" ,display.contentWidth, display.contentHeight)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2`
`local ground = display.newImage("ground.png")
ground:setReferencePoint(display.BottomLeftReferencePoint)
ground.x, ground.y = 0,420`
`local groundShape = {-420, -20, 420, -20, 420, 20, -420, 20}
physics.addBody(ground, "static", {friction = 1.0, density = 1.0, bounce = 0, shape = groundShape})`
`local char = display.newImage("char.png")
char.x = 70
char.y = 230`
`physics.addBody(char, {friction = 1.0, density = 1.0, bounce = 0.3, radius = 35})
char.isFixedRotation = true`
`local function onScreenTouch(event)
if event.phase == "began" then
char:applyForce(100, -500, char.x, char.y)
end`
`return true
end`
`end`
`Runtime:addEventListener("touch", onScreenTouch)`
`scene:addEventListener("createScene", scene)`
`return scene`
The error that I'm getting is this:
`assertion failed!
stack traceback:`
`[C]: in function 'error'
?: in function 'gotoScene'
menu.lua:17:in function '_onEvent'
?: in function '?'
?: in function <?:424>
?: in function <?:218>`
I hope that you can find a solution in this problem. Thank you.. :)