unable to cancel timers and runtimes, what am I doing wrong?

I am using a cut down version of director class; the one by Lerg in the code exchange.

It works fine but I am having issues and nightmares trying to cancel the timers and runtimes, I have a few basic questions that you may be able to help me with.

My game will end when timer reaches “0” or lives =“0”, I am trying to run a gameOver function at that point which will kill all timers and event listeners.
The lives = “0” function is in scene_bee and the timer =“0” function is in scene_game(main).

I did have this for lives =“0”

  
--bee.lua   
if lives \> 0 then  
 lifeBar[lives].isVisible = false  
 lives = lives -1  
 lifeBar[lives].isVisible = true  
 if lives \<= 0 then  
 director:changeScene('scene\_gameover')   

this is functioning correctly the only issue is that timers,runtimes and transitions where still running so the scene still played in the background less the objects I had added to localGroup.

In my scene_game(main) I added a function that contained all runtime, and timers ready for removal using timer.cancel() and nil, and removeEventListener.
I included the director:changeScene('scene\_gameover') at the end to be called last.
I then added a function calling the gameOver function.

This didnt work whatsoever even though I tried many different things, infact I had a sleepless night thinking about it (I am sure we all do).

The objects left on screen are a 2 objects that are sprites and those damn pesky leaves transitioning across the screen still.

  1. So, if I list all my timers/eventListeners in a function called gameOver, can I cancel them from a call to that function from my "lifes="0" then ( what do I do?) --function gameOver()--function.

2)How are sprite sheets dealt with? I cant add them to LocalGroup

I would like to say I am not asking you guys without trying lots of stuff first. A little guidance would be much appreciated.
[import]uid: 127675 topic_id: 31102 reply_id: 331102[/import]

I can’t recommend Lerg’s Pausable timers and transitions code strongly enough. You basically replace your timers with
[lua]transition.to(object, options)

–replace with
tnt:newTransition(object, options)[/lua]

The module allows you to pause and cancel all timers and transitions with one line. Check it out. [import]uid: 168249 topic_id: 31102 reply_id: 124354[/import]

@cooperlabs,

ok I am going to give this a go right now.

thanks [import]uid: 127675 topic_id: 31102 reply_id: 124357[/import]

ok,
I have decided to stick with the basics, I see the tnt is good but I need to understand how to

  1. cancel/remove timers properly on game end including delta
  2. cancel/remove eventlisteners on game end
  3. cancel/remove sprite sheets on game end
  4. cancel/remove transitions on game end

I need to wrap it all up in a function that can be made when lives =“0” then move to scene_gameover.
I have seriously looked and searched the forums and net but cant really find anything conclusive. [import]uid: 127675 topic_id: 31102 reply_id: 124359[/import]

I can’t recommend Lerg’s Pausable timers and transitions code strongly enough. You basically replace your timers with
[lua]transition.to(object, options)

–replace with
tnt:newTransition(object, options)[/lua]

The module allows you to pause and cancel all timers and transitions with one line. Check it out. [import]uid: 168249 topic_id: 31102 reply_id: 124354[/import]

@cooperlabs,

ok I am going to give this a go right now.

thanks [import]uid: 127675 topic_id: 31102 reply_id: 124357[/import]

ok,
I have decided to stick with the basics, I see the tnt is good but I need to understand how to

  1. cancel/remove timers properly on game end including delta
  2. cancel/remove eventlisteners on game end
  3. cancel/remove sprite sheets on game end
  4. cancel/remove transitions on game end

I need to wrap it all up in a function that can be made when lives =“0” then move to scene_gameover.
I have seriously looked and searched the forums and net but cant really find anything conclusive. [import]uid: 127675 topic_id: 31102 reply_id: 124359[/import]