The problem im having is when GameOver happens and the button apears for new screen the process (game) still runs and when I click new game (new scene to same game) it doubles up on top of the old game lol… is there a simple function to force a restart/reload using this method??
thanks in advance for your time…
top of main.lua [lua]module(…, package.seeall)
– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()[/lua]
local bt01 = display.newImage(“bt_button.png”)
local function bt01t ( event )
if event.phase == “ended” then
director:changeScene(“game”,“button”)
end
end
bt01:addEventListener(“touch”,bt01t)
bt01.x = 100
bt01.y = 300
localGroup:insert(bt01)
cueball:removeEventListener( “touch”, cueShot )
end
I don’t think you really need to reload the same file. At the game that I’m building, I have a function called initVars() where I have all the values and positions set. When I want to restart the game, I simply call it. But if you want to reload again, the best thing to do is go to a new file “gameover.lua” or something like that and go back to your game file from there.
Now talking about your code, take a look at the exemple on how to use the main.lua file.
I have on my game a pause() function where I remove all the listeners and stop transitions and timers. When I want to go back to the game, the same function recreates all of this with the state that they were. To store the state, I have a few variables just for it.
One more thing, never forget to insert your graphics into the localGroups or they will remains at the screen. [import]uid: 8556 topic_id: 5525 reply_id: 18786[/import]