one more thing then… … what is the best way to destroy and nil image files if they are created at top of an external module which is required in a level composer scene. The image files are created like this:
extern module “extmodule.lua”:
mod={} local gfx={image1,image2,image3} local init= function() gfx.image1=display.newRect(...) gfx.image2=display.newRect(...) gfx.image3=display.newRect(...) end mod.gfx=gfx return mod
And in the scene it is used like this:
local ext=require ("extmodule") local gfx=ext.gfx -- do stuff with the images in the scenes like this: -- gfx.image1.x=200 -- gfx.image1.y=100 -- ...
And then I destroy the images, when the scene has left the screen completely in the composer scene status before the destroy status like this:
for k,v in pairs( gfx ) do if v then display.remove ( v ) v=nil end end
Shouldn’t this delete everything?
What about using a function somewhere sending the image to like this:
local dosomething = function (image) image.x=300 end dosomething(gfx.image1)
And is there a difference regarding the images destruction (as seen above) when the function in the last part above is created at top of an external module like you can see below… I guess maybe the function stays in memory maybe then because the local call at top local func={dosomething} is not accessed each time the external module is loaded, but only the first time, right?
local func={dosomething} func.dosomething=function(image) image.x=300 end func.dosomething(gfx.image1)
So could it be the use of the last function causing the problems? Holding the image in memory as an instance with “image” inside the function? Even when gfx.image1 etc. are destroyed?
This would explain the water problem.