Cleaning up and Storyboard

Any time :slight_smile:

Hi,

Could please take a look at this code? I’m getting: attempt to call method ‘removeSelf’ (a nil value). What’s wrong?

The ideia is to cancel/remove timers when going to other scenes…

function scene:enterScene( event ) local function message( ) print( "timer1" ) end self.timer1 = timer.performWithDelay( 5000, message ) storyboard.gotoScene( "otherScene", { time = 500, effect = "crossFade" } ) end function scene:exitScene( event ) self.timer1:cancel( ) self.timer1:removeSelf( ) end

I think you should just do Timer.cancle(your timer id ) and then I believe that you could set it to nil

Sean:

From Boxing Studio Games

I would just do Timer.cancle (your id)
For example Timer.cancle ( timer1)
Your error mean your disposing something that doesn’t exist
Sean:
from Boxing Studio Games

Timers do not support a removeSelf() method.  After you cancel it, you can simply nil it.

Rob

Of course! Thank you again Rob and Sean :slight_smile:

anytime 

Sean:

From Boxing Studio Games Â