hi,
i would to call the red background and next destroy him and next call the green background
i thought that with
package.loaded[“level”] = nil
my background will be destroy but not.
Can you tell me why ?
thanks in advance.
--main.lua levelFunctions = require "level" levelFunctions[1]() --red background local function destroy() package.loaded["level"] = nil end timer.performWithDelay(4000, destroy() ) levelFunctions[2]() --green background local character = display.newCircle( 100, 100, 30 ) background.touch = function( event ) if event.phase == "began" then transition.to( character, {time=10, x=event.x, y=event.y} ) end end Runtime:addEventListener( "touch", background.touch)
--level.lua local levelFunctions = {}; levelFunctions[1] = function() background = display.newRect( 0, 0, 320, 480 ) background:setFillColor( 1, 0, 0 ) background.x=160 background.y=240 return background end levelFunctions[2] = function() background = display.newRect( 0, 0, 320, 480 ) background:setFillColor( 0, 1, 0 ) background.x=160 background.y=240 return background end return levelFunctions