module (..., package.seeall);
function new()
---CONSTRUCTOR---------------------------------------
local poo = display.newImage("media/poo.png");
local myrand = math.random
poo.x = myrand(50, 400); poo.y = myrand(50,300);
-----------------------------------------------------
function remove\_monster( object )
if object ~= nil then
print("remove\_monst");
display.remove(object);
object = nil;
end
end
function poo:destroy()
display.remove(self)
self = nil
end
transition.to( poo, { time=1000, y=500, alpha=0, onComplete=remove\_monster } )
-----------------------------------------------------
-- Listener to Touch Screen
-----------------------------------------------------
function touch(e)
if (e.phase == "ended") then
local splash = display.newImage("media/poo\_splash".. math.random(1,5) ..".png");
transition.to( splash, { time=100, alpha=0, onComplete=destroy} )
--transition.to( splash, { time=100, alpha=0, onComplete=function() remove\_monster(poo); end;} )
end
return true;
end
-----------------------------------------------------
-- Listener
-----------------------------------------------------
poo:addEventListener( "touch", touch );
return poo;
end
Hi everybody,
i have the problem to destroy the object in the same class.
For example: when the transition complete, remove the object from the display and from the memory.
If i use the function destroy (OUTSIDE THE MODULE) there is no problem. But inside the module don’t work… don’t delete the memory!
Can somebody help me?!?! I need to free the memory calling a function INSIDE the module class.
Thank you so much.
[import]uid: 153233 topic_id: 27439 reply_id: 327439[/import]
[import]uid: 153233 topic_id: 27439 reply_id: 112004[/import]