@carloscosta - I’ll PM this to you in case you’re not continuing to read this thread, but I’m posting it here because I hope to be at least a little helpful to you and others.
In your post above I noticed you said something about hating Runtimes.
I’m guessing this may be because it is easy to get crashes with Runtimes like ‘enterFrame’ and/or custom Runtime event listeners.
For example, this code using a table listener would crash:
local obj = display.newCircle( 100, 100, 100 ) obj.enterFrame = function( self ) self.x = self.x + 10 end Runtime:addEventListener( "enterFrame", obj ) timer.performWithDelay( 1000, function() display.remove(obj) ) end)
To prevent a crash you can do this:
local obj = display.newCircle( 100, 100, 100 ) obj.enterFrame = function( self ) self.x = self.x + 10 end Runtime:addEventListener( "enterFrame", obj ) function obj.finalize( self ) Runtime:removeEventListener( "enterFrame", self ) end obj:addEventListener( "finalize" ) timer.performWithDelay( 1000, function() display.remove(obj) ) end)
PS - I’m always mentioning SSK2 (now free), but in this case it has a handy feature for safely cleaning up Runtime listeners.
The safe code above would look like this in SSK2:
local obj = display.newCircle( 100, 100, 100 ) obj.enterFrame = function( self ) self.x = self.x + 10 end listen( "enterFrame", obj ) function obj.finalize( self ) ignoreList( { "enterFrame" } , self ) -- add more event names to table to safely remove them. end obj:addEventListener( "finalize" ) timer.performWithDelay( 1000, function() display.remove(obj) ) end)