I am making a game that has a level contained in a lua module. Something like this.
level.lua:
function newLevel(data)
local level = display.newGroup()
level.physics = require "physics"
level.physics.start()
-- make the level here
return level
end
And in my main.lua I am creating these levels.
main.lua:
require "level"
level1 = newLevel(data\_for\_level1)
level2 = newLevel(data\_for\_level2)
level1.start()
At some point, the user will finish level 1 and I will send them to level 2. The physics world created in level 1 looks like it is still around and makes the play for the next level not work properly. I would like to be able to keep all of the levels in tact because the user can go back to previous levels in their last state.
So what is the appropriate design for circumstances like this? I’ve tried to do a level.physics.stop()
but that doesn’t seem to work. Saving all of the world data and destroying it upon going to another level and recreating upon reentering sounds like ugly design.
Thanks in advance! [import]uid: 213270 topic_id: 35957 reply_id: 335957[/import]