Refresh Screen

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]

if you don’t want to go to the home screen you can just reset the global variables you have set through the paths of the game and go to the screen you want. [import]uid: 71210 topic_id: 14084 reply_id: 51877[/import]

I don’t have a problem changing screens. I’m having a problem with the game refreshing after the play again button is tapped. It goes to the right screen though. [import]uid: 72372 topic_id: 14084 reply_id: 51878[/import]

if its going to the right scene then what is the difference you are seeing from a new game ? [import]uid: 71210 topic_id: 14084 reply_id: 51881[/import]

Okay like I said I have two paths… let’s look at it this way.

Player goes Path one gets a result game over then presses play again. If they take path one again everything is great and they get a new result.

BUT…if they select play again and choose path two the result they get is the same result from path one in the previous game. It should be a different result.

The only way to fix that is to close the game out and start over completely.

How do I fix that so it truly rests after the play it again button is clicked…? [import]uid: 72372 topic_id: 14084 reply_id: 51886[/import]

Does anybody have any idea how I can reset my game without the user going to the home screen. I don’t mean going back to the menu screen, i know how to do that with director and I’m doing it. I’m trying to clear out data that was used during the previous game. So set everything back to a new game. How do I do that? The code is above.

Michelle [import]uid: 72372 topic_id: 14084 reply_id: 52000[/import]