director:changeScene does not return to scene that you calledm

Hi All,

i have a problem using function clean() in director class.

is this as simple as 

function clean()     print("join\_game lua is cleaned?") end ?  

or 

function clean()     codes that will clean the scene ? end  

and where is the function clean() will be called upon ?

my main problem is that after my game.lua scene, i will go back to my create_join_game page.

local function onComplete( event )                 if "clicked" == event.action then                     local i = event.index                     if 1 == i then                         timer.cancel ( timedId )                         director:changeScene("create\_join\_game", "overFromBottom")                     end                 end             end             local alert = native.showAlert( "Alert", status\_msg,                                         { "End" }, onComplete )         end     end  

when End alert is clicked. it should be going to “create_join_game page” but it is stock at the “game” page and it shows that is no error!

please help me. thank you in advance 

does anyone willing to help ? please help me.

Please wait a couple of days (at least 24 hours) before bumping your thread.   It takes people time to respond.

I think it would also help to post a little more code.

i’m sorry, i’m just in a rush to our project. please understand.

my main problem is that when the game.lua is finished, the scene reload back at create_game.lua, and within the create_game.lua, it will go to set.up.lua page. the values in that set_up.lua  is retained, i dont know where to put the clean() function of director so that when it goes back to set_up.lua you can set up new pieces

we’re also using parsing, it works well. 

game.lua endgame function() when the game is finished.

module(..., package.seeall) module("create\_game", package.seeall) module("set\_up", package.seeall) module("set\_up2", package.seeall) local M = {} require "create\_game "require "set\_up" require "set\_up2" local function new() function endGame(event)         if(event.isError) then             print("Network error!")             local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )         else             local data = event.response             local xml = require("xml").newParser()             local xmlText = xml:ParseXmlText(data)             local ResponseCode = xmlText.child[2].value             local ResponseMessage = xmlText.child[3].value             status\_msg = ResponseMessage             print(status\_msg)             local function onComplete( event )                 if "clicked" == event.action then                     local i = event.index                     if 1 == i then                         timer.cancel ( timedId )                         director:changeScene("create\_join\_game", "overFromBottom")                     end                 end             end             local alert = native.showAlert( "Alert", status\_msg,                                         { "End" }, onComplete )         end     end     function player\_status()         local URL = "URL"         network.request(URL, "GET", endGame)     end  

it must go back here in create_game.lua

module(..., package.seeall) local M = {} local function new()     print "create\_game.lua"     local mainGroup = display.newGroup()     local function  onKeyMenu  (event)         local phase = event.phase         local keyName = event.keyName         if event.keyName=="back" then             alertyow()         end                  return true     end     Runtime:addEventListener( "key", onKeyMenu )     local \_W = display.contentWidth     local \_H = display.contentHeight     local textFont = native.newFont( native.systemFont )     local device\_address = system.getInfo("deviceID")     print ("Device Address:" .. device\_address)     ----------------------------------------     ---------- \*\*\*\* Parsing \*\*\*\* -----------     ----------------------------------------         local function createGameId(event)             audio.stop( button\_audio\_play )             if(event.isError) then                 print("Network error!")                 local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )             else                 local data = event.response                 print("my xml response")                 print(data)                 local xml = require("xml").newParser()                 local xmlText = xml:ParseXmlText(data)                 local ResponseCode = xmlText.child[2].value                 local ResponseMessage = xmlText.child[3].value                 GameId = xmlText.child[4].child[1].value                 print ("Response code:" .. ResponseCode)                 print (ResponseMessage)                 print ("Game #:" .. " " .. GameId .. " " .. "created")             local URL ="URL"             network.request(URL, "GET", createPlayerId)             --------------------------------------------             end         end         function createPlayerId(event)             if(event.isError) then                 print("Network error!")                 local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )             else                 local data = event.response                 print("my xml response")                 print(data)                 local xml = require("xml").newParser()                 local xmlText = xml:ParseXmlText(data)                 local ResponseCode= xmlText.child[2].value                 local ResponseMessage = xmlText.child[3].value                 PlayerId = xmlText.child[4].child[1].value                 print ("Response code:" .. ResponseCode)                 print (ResponseMessage)                 print ("PlayerId" .. " " .. PlayerId .. " " .. "created")                 director:changeScene("set\_up", "overFromBottom")             end         end     local bg = display.newImageRect("images/backgrounds/setup\_bg.jpg",720,1280)     bg.x = \_W\*0.5; bg.y = \_H\*0.5;     local menu\_audio = audio.loadSound("audio/gamebattle\_audio.wav")     local menu\_audio\_play = audio.play(menu\_audio, {channel=1, loops=-1, fadein=0})     mainGroup:insert(bg)     -- GameName Text     local gameNameText = display.newText("Enter Game Name:",0,0,"Helvetica",20)     gameNameText:setTextColor(0,0,0)     gameNameText.x = \_W\*0.5; gameNameText.y = \_H-400     mainGroup:insert(gameNameText)     -- create textField     roomtextField = native.newTextField( 10, 150, display.contentWidth - 20, 36 )     roomtextField.font = textFont     roomtextField.size = 14     roomtextField.text = myText     -- calls text box function --     --txtbox()     -------- create button function --------------     function createBtnPress(event)         print (myText)             native.setKeyboardFocus( nil )             audio.stop( menu\_audio\_play )             local button\_audio = audio.loadSound("audio/clickButton\_audio.mp3")             local button\_audio\_play = audio.play(button\_audio, {channel=2, loops=0, fadein=0})                          local URL = "URL"             network.request(URL, "GET", createGameId)             return true     end     function cancelBtnPress(event)         audio.stop( menu\_audio\_play )         local button\_audio = audio.loadSound("audio/clickButton\_audio.mp3")         local button\_audio\_play = audio.play(button\_audio, {channel=2, loops=0, fadein=0})         director.changeScene("create\_join\_game", "overFromBottom")         audio.stop( button\_audio\_play )         return true     end     ------------------- Initializations of buttons ----------------------     local createBtn = display.newImageRect("images/buttons/create.png",223,39)     createBtn.x = \_W\*0.5; createBtn.y = \_H\*0.5     --createBtn.alpha = 0.01     createBtn.value = textOut     createBtn:addEventListener("tap", createBtnPress)     mainGroup:insert(createBtn)     local cancelBtn = display.newImageRect("images/buttons/backButton.png",223,39)     cancelBtn.x = \_W\*0.5; cancelBtn.y = \_H\*0.6     --createBtn.alpha = 0.01     cancelBtn:addEventListener("tap", cancelBtnPress)     mainGroup:insert(cancelBtn)     --Return a group so director can remove it all...     return mainGroup end M.new = new return M  

and here is the set_up.lua module. the values here is RETAINED from the previous game.

module("create\_game", package.seeall) module("set\_up", package.seeall) local M = {} require "create\_game" require "set\_up" local function new()         local function gameStatus()         local URL ="URL"         network.request(URL, "GET", getGameStatus)         --print(game\_status)         Toast = toast.new("Waiting for other player", 1000)     end     timerId = timer.performWithDelay(2000, gameStatus, 0)     function getPlayerStatus(event)             if(event.isError) then                 print("Network error!")                 local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )             else                 local data = event.response                 --print("my xml response")                 --print(data)                 local xml = require("xml").newParser()                 local xmlText = xml:ParseXmlText(data)                 local ResponseCode = xmlText.child[2].value                 local ResponseMessage = xmlText.child[3].value                 player\_status = xmlText.child[4].child[1].value                 --print ("Response code:" .. ResponseCode)                 --print (ResponseMessage)                 --print ("gameStatus #:" .. " " .. game\_status .. " " .. "created")                 print(player\_status)                 if player\_status == "Yes" then                     timer.cancel ( playerTimer )                     director:changeScene("game", "overFromBottom")                     Toast = toast.new("Game ready", 2000)                 end             end     end  

i’m hoping that the scene will reload in the set_up.lua page but the values from the previous game is retained and the player can’t set up a new page because of it.

Your code confuses me a bit.  I’ve never seen someone have multiple “module” lines in a module.  I don’t know what that behavior would be.

But I think the bigger issue is that you’re declaring a bunch of global functions.  I still don’t see where you’re creating the clean function, but if you leave the “local” off of them  (and you’re not adding functions to object tables) then you’re overwriting any function with the same name.

does anyone willing to help ? please help me.

Please wait a couple of days (at least 24 hours) before bumping your thread.   It takes people time to respond.

I think it would also help to post a little more code.

i’m sorry, i’m just in a rush to our project. please understand.

my main problem is that when the game.lua is finished, the scene reload back at create_game.lua, and within the create_game.lua, it will go to set.up.lua page. the values in that set_up.lua  is retained, i dont know where to put the clean() function of director so that when it goes back to set_up.lua you can set up new pieces

we’re also using parsing, it works well. 

game.lua endgame function() when the game is finished.

module(..., package.seeall) module("create\_game", package.seeall) module("set\_up", package.seeall) module("set\_up2", package.seeall) local M = {} require "create\_game "require "set\_up" require "set\_up2" local function new() function endGame(event)         if(event.isError) then             print("Network error!")             local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )         else             local data = event.response             local xml = require("xml").newParser()             local xmlText = xml:ParseXmlText(data)             local ResponseCode = xmlText.child[2].value             local ResponseMessage = xmlText.child[3].value             status\_msg = ResponseMessage             print(status\_msg)             local function onComplete( event )                 if "clicked" == event.action then                     local i = event.index                     if 1 == i then                         timer.cancel ( timedId )                         director:changeScene("create\_join\_game", "overFromBottom")                     end                 end             end             local alert = native.showAlert( "Alert", status\_msg,                                         { "End" }, onComplete )         end     end     function player\_status()         local URL = "URL"         network.request(URL, "GET", endGame)     end  

it must go back here in create_game.lua

module(..., package.seeall) local M = {} local function new()     print "create\_game.lua"     local mainGroup = display.newGroup()     local function  onKeyMenu  (event)         local phase = event.phase         local keyName = event.keyName         if event.keyName=="back" then             alertyow()         end                  return true     end     Runtime:addEventListener( "key", onKeyMenu )     local \_W = display.contentWidth     local \_H = display.contentHeight     local textFont = native.newFont( native.systemFont )     local device\_address = system.getInfo("deviceID")     print ("Device Address:" .. device\_address)     ----------------------------------------     ---------- \*\*\*\* Parsing \*\*\*\* -----------     ----------------------------------------         local function createGameId(event)             audio.stop( button\_audio\_play )             if(event.isError) then                 print("Network error!")                 local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )             else                 local data = event.response                 print("my xml response")                 print(data)                 local xml = require("xml").newParser()                 local xmlText = xml:ParseXmlText(data)                 local ResponseCode = xmlText.child[2].value                 local ResponseMessage = xmlText.child[3].value                 GameId = xmlText.child[4].child[1].value                 print ("Response code:" .. ResponseCode)                 print (ResponseMessage)                 print ("Game #:" .. " " .. GameId .. " " .. "created")             local URL ="URL"             network.request(URL, "GET", createPlayerId)             --------------------------------------------             end         end         function createPlayerId(event)             if(event.isError) then                 print("Network error!")                 local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )             else                 local data = event.response                 print("my xml response")                 print(data)                 local xml = require("xml").newParser()                 local xmlText = xml:ParseXmlText(data)                 local ResponseCode= xmlText.child[2].value                 local ResponseMessage = xmlText.child[3].value                 PlayerId = xmlText.child[4].child[1].value                 print ("Response code:" .. ResponseCode)                 print (ResponseMessage)                 print ("PlayerId" .. " " .. PlayerId .. " " .. "created")                 director:changeScene("set\_up", "overFromBottom")             end         end     local bg = display.newImageRect("images/backgrounds/setup\_bg.jpg",720,1280)     bg.x = \_W\*0.5; bg.y = \_H\*0.5;     local menu\_audio = audio.loadSound("audio/gamebattle\_audio.wav")     local menu\_audio\_play = audio.play(menu\_audio, {channel=1, loops=-1, fadein=0})     mainGroup:insert(bg)     -- GameName Text     local gameNameText = display.newText("Enter Game Name:",0,0,"Helvetica",20)     gameNameText:setTextColor(0,0,0)     gameNameText.x = \_W\*0.5; gameNameText.y = \_H-400     mainGroup:insert(gameNameText)     -- create textField     roomtextField = native.newTextField( 10, 150, display.contentWidth - 20, 36 )     roomtextField.font = textFont     roomtextField.size = 14     roomtextField.text = myText     -- calls text box function --     --txtbox()     -------- create button function --------------     function createBtnPress(event)         print (myText)             native.setKeyboardFocus( nil )             audio.stop( menu\_audio\_play )             local button\_audio = audio.loadSound("audio/clickButton\_audio.mp3")             local button\_audio\_play = audio.play(button\_audio, {channel=2, loops=0, fadein=0})                          local URL = "URL"             network.request(URL, "GET", createGameId)             return true     end     function cancelBtnPress(event)         audio.stop( menu\_audio\_play )         local button\_audio = audio.loadSound("audio/clickButton\_audio.mp3")         local button\_audio\_play = audio.play(button\_audio, {channel=2, loops=0, fadein=0})         director.changeScene("create\_join\_game", "overFromBottom")         audio.stop( button\_audio\_play )         return true     end     ------------------- Initializations of buttons ----------------------     local createBtn = display.newImageRect("images/buttons/create.png",223,39)     createBtn.x = \_W\*0.5; createBtn.y = \_H\*0.5     --createBtn.alpha = 0.01     createBtn.value = textOut     createBtn:addEventListener("tap", createBtnPress)     mainGroup:insert(createBtn)     local cancelBtn = display.newImageRect("images/buttons/backButton.png",223,39)     cancelBtn.x = \_W\*0.5; cancelBtn.y = \_H\*0.6     --createBtn.alpha = 0.01     cancelBtn:addEventListener("tap", cancelBtnPress)     mainGroup:insert(cancelBtn)     --Return a group so director can remove it all...     return mainGroup end M.new = new return M  

and here is the set_up.lua module. the values here is RETAINED from the previous game.

module("create\_game", package.seeall) module("set\_up", package.seeall) local M = {} require "create\_game" require "set\_up" local function new()         local function gameStatus()         local URL ="URL"         network.request(URL, "GET", getGameStatus)         --print(game\_status)         Toast = toast.new("Waiting for other player", 1000)     end     timerId = timer.performWithDelay(2000, gameStatus, 0)     function getPlayerStatus(event)             if(event.isError) then                 print("Network error!")                 local function onComplete( event )                 if "clicked" == event.action then                         local i = event.index                         if 1 == i then                                 showMenu()                         elseif 2 == i then                               os.exit()                         end                 end             end             local alert = native.showAlert( "Alert", "No Internet Connection Please try Again ",                                                     { "Retry", "Close" }, onComplete )             else                 local data = event.response                 --print("my xml response")                 --print(data)                 local xml = require("xml").newParser()                 local xmlText = xml:ParseXmlText(data)                 local ResponseCode = xmlText.child[2].value                 local ResponseMessage = xmlText.child[3].value                 player\_status = xmlText.child[4].child[1].value                 --print ("Response code:" .. ResponseCode)                 --print (ResponseMessage)                 --print ("gameStatus #:" .. " " .. game\_status .. " " .. "created")                 print(player\_status)                 if player\_status == "Yes" then                     timer.cancel ( playerTimer )                     director:changeScene("game", "overFromBottom")                     Toast = toast.new("Game ready", 2000)                 end             end     end  

i’m hoping that the scene will reload in the set_up.lua page but the values from the previous game is retained and the player can’t set up a new page because of it.

Your code confuses me a bit.  I’ve never seen someone have multiple “module” lines in a module.  I don’t know what that behavior would be.

But I think the bigger issue is that you’re declaring a bunch of global functions.  I still don’t see where you’re creating the clean function, but if you leave the “local” off of them  (and you’re not adding functions to object tables) then you’re overwriting any function with the same name.