local lives = 5 -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view local question = display.newText ("WNumber 1 is the correct number?", 0, 0, native.systemFont, 18) question.x = display.contentCenterX question.y = display.contentCenterY local livesLabel = display.newText("Lives:" ..tostring(lives), 10, 30, native.systemFont, 16) livesLabel.x = display.contentCenterX livesLabel.y = display.contentCenterY -100 local isCorrect = display.newText ("Number 1", 0, 0, native.systemFont, 18) isCorrect.x = display.contentCenterX isCorrect.y = display.contentCenterY + 100 local bgImage1 = display.newText ("Number 2", 0, 0, native.systemFont, 18) bgImage1.x = display.contentCenterX bgImage1.y = display.contentCenterY + 80 local bgImage2 = display.newText ("Number 3", 0, 0, native.systemFont, 18) bgImage2.x = display.contentCenterX bgImage2.y = display.contentCenterY + 120 local bgImage = display.newText ("Number 4", 0, 0, native.systemFont, 18) bgImage.x = display.contentCenterX bgImage.y = display.contentCenterY + 140 -- local livesLabel = display.newText("Lives:" ..tostring(lives), 10, 30, native.systemFont, 16) -- livesLabel.x = display.contentCenterX +100 -- livesLabel.y = display.contentCenterY - 200 local function isCorrectTap( event ) storyboard.gotoScene("levels.question2") print(" Next question") end isCorrect:addEventListener("tap", isCorrectTap ) group:insert( isCorrect ) local function bgTap( event ) lives = lives - 1 livesLabel.text = "Lives:" ..tostring(lives) print("Lives Left:" .. lives) end bgImage:addEventListener("tap", bgTap ) bgImage1:addEventListener("tap", bgTap ) bgImage2:addEventListener("tap", bgTap ) group:insert( bgImage ) end
When I made a new file with pretty much the same thing as this one. and did storyboard.gotoScene(“levels.question2”).
When I press the button that goes to the Scene question2. The scene overlaps the original scene. The original scene doesn’t disappear.
2nd problem. Right now if you press the wrong option. It decreases the lives value by 1. So I press the wrong answer twice. I would have 3 lives left. After I get the question right and go to the scene question2 How would I be able use the number of lives left over from the first scene in the 2nd scene?