Hi all
i would like to load/reuse levels as below but when level2 is loaded the physics collissions do not work, please help!
– physics
local physics = require(“physics”)
physics.start()
physics.setGravity( 0, 0 )
physics.setDrawMode( “hybrid” )
local walls = display.newGroup()
local wall
local door
local level = 1
local function level1()
local wall = display.newRect(tilesize * 2, tilesize * 2,tilesize, tilesize)
wall.name = “wall”
physics.addBody(wall, “static”, { bounce=0, friction=0 } )
wall:setFillColor(55, 55, 55, 255)
walls.insert(walls, wall)
end
local function level1()
local wall = display.newRect(tilesize * 3, tilesize * 3,tilesize, tilesize)
wall.name = “wall”
physics.addBody(wall, “static”, { bounce=0, friction=0 } )
wall:setFillColor(55, 55, 55, 255)
walls.insert(walls, wall)
end
local function updatelevel()
for i = walls.numChildren,1,-1 do
local wall = walls[i]
if wall.name ~= nil then
wall:removeSelf()
wall.name=nil
end
end
if level == 1 then
level2()
level = 2
elseif level == 2 then
level1()
level = 1
end
end
Thx
Sparrow