How do I refresh my game when I want to start it over and Play Again? I have a final screen that I have a Play Again button that uses director class 1.3 to take you back to the first screen. In my game there are two paths you can take to play the game. On pathOne there are several boxes you have to enter to get a result on the last screen and this path is working fine.
The second path, pathTwo only has one box that you have to enter before you get to the last screen with a result and this is the screen that is having the problem.
If I go down pathOne and complete the game then hit Play Again on the last screen and switch to PathTwo the easier path. The result that I just got from PathOne is the same result I will get on PathTwo.
The only way to truly reset PAthTwo right now is to go to the home screen on the device and then come back in the game and I DON’T want that.
How do I clean up the remnants of the previous game regardless of the path choosing? I already remove the listeners but I have posted the code below.
[lua]module(…, package.seeall)
function new()
local localGroup = display.newGroup()
local inputFontSize = 80
local inputFontHeight = 80
local tHeight = 100
local ui = require(“ui”)
local screen9 = display.newImage (“screen9.png”)
localGroup:insert(screen9)
–> This sets Screen9
local play = display.newImage (“play.png”)
play.x = 100
play.y = 55
play.xScale = .5
play.yScale = .5
localGroup:insert(play)
local function touchedPlay (event)
if (“ended” == event.phase) then
director:changeScene (“titlescreen”, “fade”)
media.playEventSound( “click_x.caf” )
end
end
play:addEventListener (“touch”, touchedPlay)
local cleanUp = function()
rateitbutton:removeEventListener(“touch”, doRating)
play:removeEventListener (“touch”, touchedPlay)
end
local digitSum = 0
local reminder
if number ~=nil then
while number ~=0 do
reminder = number % 10
end
end
local function onnumberFieldReminder( event )
if ( “ended” == event.phase ) or ( “submitted” == event.phase ) then
end
end
– showinf the reminder in a textfield
numberFieldReminder = native.newTextField( 180, 315, 85, tHeight, onnumberFieldReminder)
numberFieldReminder.font = native.newFont( native.systemFontBold, inputFontSize )
numberFieldReminder.inputType = “number”
numberFieldReminder.align = “center”
numberFieldReminder.text = divisionBal[/lua] [import]uid: 72372 topic_id: 14084 reply_id: 314084[/import]