Hi everyone.
I am new to corona.
Currently i am creating a very simple physics ballon game mostly to test and experiment with the storyboard.
So, i have a welcoming screen and a game screen. At the first screen i press “start game” and moves to scene2.lua.
When the balloon hits the floor the game stops and a screen appears asking if the player wants to play again or not. The problem is with the listener i have on the “Yes” (In my code it is mentioned as “Nai”) which is a simple text variable. Note that the error pops out as soon as the game screen comes out.
I know that my problem is very simple but i can’t think of what else to try.
Here is my code if someone wants to take a look
----------------------------------------------------------------------------------------- -- -- scene2.lua -- ----------------------------------------------------------------------------------------- -- Your code here local storyboard = require "storyboard" local scene = storyboard.newScene() local button2 local function onSceneTouch( event ) if event.phase == "began" then storyboard.gotoScene( "scene3", "zoomInOutFadeRotate", 800 ) return true end end -- function restart( event ) -- if event.phase == "began" then -- storyboard.gotoScene( "scene2", "zoomInOutFadeRotate", 800 ) -- return true -- end -- end function scene:createScene( event ) local screenGroup = self.view local koumpia = self.view background = display.newImage("background.jpg") score = 0 scoreText = display.newText("Your score is: " .. score, 0,0, native.systemFontBold, 50) scoreText:setTextColor(0,0,0) balloon = display.newImage("balloon.png") balloon.x=display.contentWidth\*0.5 --floor floor = display.newImage("floor.png") floor.y = display.contentHeight - floor.contentHeight\*0.5 screenGroup:insert( background ) screenGroup:insert( scoreText ) screenGroup:insert( balloon ) screenGroup:insert( floor ) --screenGroup:insert( Nai ) --screenGroup:insert( Oxi ) end function scene:enterScene( event ) function moveBalloon(event) balloon = event.target balloon:applyLinearImpulse(0, -0.5, event.x, event.y) score=score+1 scoreText.text= "Your score is: " .. score end function resetScore(event) gameLost = display.newRect(-100,0,display.contentWidth+200, display.contentHeight) gameLost:setFillColor(0,0,0) lost = display.newText("Exases. To score sou einai: " .. score, 0, display.contentHeight\*0.5, native.systemFontBold, 50) lost:setTextColor(128,128,128) restart = display.newText("Thes na ksanapaikseis?", 0, display.contentHeight\*0.5+50, native.systemFontBold, 50) restart:setTextColor(0,255,0) Nai = display.newText("Nai", display.contentWidth\*0.25, display.contentHeight\*0.5+100, native.systemFontBold, 50) Nai:setTextColor(255,0,0) Oxi = display.newText("Oxi", display.contentWidth\*0.75, display.contentHeight\*0.5+100, native.systemFontBold, 50) Oxi:setTextColor(0,0,255) end physics = require("physics") physics.start() physics.setGravity(0, 9.8) physics.addBody(balloon,{ bounce = 0.8, radius = 45, friction = 1.0}) physics.addBody(floor, "static", {friction = 1.0}) 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) --place the walls physics.addBody(leftWall, "static", {bounce = 0.1}) physics.addBody(rightWall, "static", {bounce = 0.1}) physics.addBody(ceiling, "static", {bounce = 0.1}) -- remove previous scene's view storyboard.purgeScene( "scene1" ) balloon:addEventListener("touch", moveBalloon) floor:addEventListener("collision", resetScore) Nai:addEventListener("touch", onSceneTouch) end function scene:exitScene( event ) balloon:removeEventListener("touch", moveBalloon) floor:removeEventListener("collision", resetScore) Nai:removeEventListener("touch", onSceneTouch) end function scene:destroyScene( event ) end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene