Q: Do I need to cancel transitions that do not have an handle?

Hey guys, here something i always wanted know. Say I have a transition like this:

transition.to( gameOverScreen, { time=500, alpha=1 } )

Now, do I need to manually cancel this transition or is it ok to leave it alone. I am using Director. My understanding is that we need to cancel all transitions. This one do not have an handle. I usual do not use too many transitions because I will give them and handle (so I can cancel them in my clean()) but if I did not have to cancel transition without an handle that would be great since i will not keep track of most of them.

Just curious.

Mo

EDIT: I guess the follow question would be: Is it ok to use transitions (or timer) with handles? It seems that new Corona book use them many times over…

[import]uid: 100814 topic_id: 25938 reply_id: 325938[/import]

My understanding and I could be very wrong, is that timers and transitions will go away on their own when they are done. Their memory should be freed up, nilled out and garbage collected and that you only need to cancel them if you need to end them prematurely.

With my first game, I was very careful to always get handles on them and to make sure I did a check on the handle when it was done:

  
if timerHandle ~= nil then  
 timer.cancel(timerHandle)  
 tiimerHandle = nil  
end  
  

But in my old age I’ve broken myself of that and there seems to be no leakage or problems when I don’t get rid of everything by hand.

[import]uid: 19626 topic_id: 25938 reply_id: 104990[/import]

Thanks Rob! Yes I am doing exactly like you (using handles) but it is not much fun to keep track of them. My understanding (and i could be wrong too!) is that timers and transitions need to be canceled. At least it is true of timers/transitions with handles. I really never seen or dealt with those objects without an handle. I do not think it should make any difference but to how cancel timers/trans that do not have handles?

But if you say you do not see any issues then i may just forget about it. Maybe the good people at Ansca can tell us more.

Thanks Rob.

Mo [import]uid: 100814 topic_id: 25938 reply_id: 104991[/import]

I don’t know if attaching a handle necessarily keeps the timer/transition in memory. Can anybody confirm this? I know that in general, you do NOT need to explicitly cancel timers or transitions unless you want to, for some app-specific purpose.

You can also cancel timers without handles when they execute, by simply using the “event.” reference in the target function ( I think it’s “event.source” but I’m typing on my iPad now and can’t look at my code to confirm it). But, this shouldn’t even be necessary if timers and transitions become eligible for garbage collection when they’re finished.

Brent Sorrentino [import]uid: 9747 topic_id: 25938 reply_id: 105013[/import]

I have a feeling it’s a good idea to keep a handle to every transition so you CAN cancel it.
Eg if you have things moving about onscreen and get a GAME OVER or LEVEL UP. You start the next level and transitions are still happening from the previous level. [import]uid: 10389 topic_id: 25938 reply_id: 105248[/import]

Thanks guys, good points!

Mo [import]uid: 100814 topic_id: 25938 reply_id: 105254[/import]

It’s better to create a handle/reference for any timer or transition.

Take for instance this scenario.

You are in your main menu, you are flashing “tap to play” using a series of transitions. None of your transitions have a handle, when you hit “tap to play” to change scenes your going to immediately hit a runtime error or if your unlucky and you don’t, that is going to stay active until your scene is purged.

It’s always a good idea to keep a handle on everything so you can remove/stop/cancel them when needed [import]uid: 84637 topic_id: 25938 reply_id: 105902[/import]