Okay it’s still not working. What am I doing wrong. Just so I can refresh what is happening. I have a game that you have two paths you can choose to play the game and for each path it gives a result on the last screen. You can then choose the play again button which takes you back to the first screen. I am finding that if you choose path one every time the game works fine but if you choose Path One and then hit the play again button and go to path two the result will give you the answer you had from path one.
I am trying to reset the game so that every time you play or play again you get a fresh start. I am adding the text field = nil but that’s not working. Here is my code.
[lua]module(…, package.seeall)
function new()
local localGroup = display.newGroup()
local inputFontSize = 80
local inputFontHeight = 80
local tHeight = 100
local ui = require(“ui”)
local number
if _G.numberSix ~= nil then
number = _G.numberSix
elseif _G.numberTen ~= nil then
number = _G.numberTen
else
number = 0
end
local screen9 = display.newImage (“screen9.png”)
localGroup:insert(screen9)
–> This sets Screen9
–>This is how we reset the level
local playbutton = display.newImage (“play.png”)
localGroup:insert(playbutton)
playbutton.x = 100
playbutton.y = 55
playbutton.xScale = .5
playbutton.yScale = .5
local function playbuttonfn (event)
numberFieldReminder.text = nil
director:changeScene( “titlescreen”, “flip” )
media.playEventSound( “bloop_x.caf” )
end
playbutton:addEventListener (“tap”, playbuttonfn)
local rateit = display.newImage (“rateit.png”)
rateit.x = 225
rateit.y = 55
rateit.xScale = .5
rateit.yScale = .5
localGroup:insert(rateit)
–>This places the rateit button
local function doRating(event)
if event.phase == “ended” then
local url = “itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa”
url = url … “/wa/viewContentsUserReviews?”
url = url … “type=Purple+Software&id=”
url = url … “453641732”
system.openURL(url)
end
end
rateit:addEventListener(“touch”, doRating)
–> Adds the Rate It functionality. Be sure to change the APP ID to your OWN;
local cleanUp = function()
rateitbutton:removeEventListener(“touch”, doRating)
play:removeEventListener (“touch”, touchedPlay)
end
local function onnumberFieldReminder( event )
if ( “ended” == event.phase ) or ( “submitted” == event.phase ) then
end
end
– show 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
localGroup:insert(numberFieldReminder)
–>MUST return a display.newGroup()
–> This is how we end every file except for director and main, as mentioned in my first comment
return localGroup
end[/lua] [import]uid: 72372 topic_id: 14134 reply_id: 52284[/import]