Does transitions.pause, cancel work on transitions with onComplete function which have nested transitions.

I have a lot of transitions with onComplete functions which in turn have nested transitions. I read somewhere its better to call transition.pause/ transition.cancel twice to be on the safer side.

The scenario is when I’m switching scenes I just call the transition.cancel(tag) – to cancel all transitions with the particular tag.

The player hits the pause button I just call the transition.pause(tag) – to pause all transitions.

So should I be calling it twice, because some transitions are called using infinite loop timers.

Is it really necessary?

– Example of nested transitions

function callTransition() transition.to(object, {time = 1000, x = 100 ,onComplete = function() transition.to(object, {time = 1000, x = 200, onComplete = function() callTransition() end}) end }) end

I think your actual question should be, “When I cancel a transition, does onComplete() get called?”

If not, then you don’t have to cancel twice.

If so, then you do.

You can determine this experimentally.

Tip: You mention an infinite timer.  These are problematic.  You should reconsider that choice or be sure you can pause and/or that timer when needed.

Why?  Well, if you pause or cancel all transitions, then the timer trips and creates a new transition, it will not be paused.

Yea, roaminggamer . I have created a table to hold the references of all those infinite timers. So I go in this order:-

  • I pause the timers.

  • pause the transitions

  • remove the enterFrame events

  • pause the transitions again.

I read a forum post somewhere to pause/cancel transitions twice. I can’t seem to locate that post again.

So to be on the safer side, I wish to pause/cancel transitions twice. Is there any side effects to it. 

I don’t think there will be any negative side-effects.

Sure then, thanks for clarifying roaming gamer. I was going through your composer module on github. Its really helpful in clarifying some of the doubts I had.

@Quitalizner,

Hi.  I have two random question:

  1. What is your native language?

  2. Did you use a translator to post you comments/questions?

I am asking this purely out of curiosity and to learn something.  I have noticed that certain writers use the word ‘doubt’ when the grammatically correct word is ‘question’.

I have seen this for various languages and I am trying to form a mental map (if you will) correlating common mistakes to OPs native language.  I am a language lover and enjoy working out little puzzles like this.

PS - If your native language is English, this will be even more fascinating, as it may indicate external influences to your word choices or a change in the language itself.  However I doubt this, no pun intended. :slight_smile:

d24a49344c09812a55e7aeb60a4d516d.jpg

Sorry for jumping in here, but after I read these posts I only got confused and I’d like to make sure I didn’t confuse myself too profoundly.

For what reason would you ever need to cancel a timer or a transition twice? Sure, there won’t be any problems with double pausing, but why would this be needed in the first place? Am I just confused with the idea of zombie transitions with onCompletes jumping out of the woodwork or should I just go back to enjoying my tea, being happy to just cancel everything once like I’ve always done? :smiley:

@roaminggamer.

It’s funny that you ask that question. I find myself in confusion sometimes, whether to use the word doubt or question. Thanks for clearing this for me.

Yes, my native language isn’t English. But English has been my second language. I didn’t pay much attention while learning grammar in school, I’m repenting for that now.

@XeduR

I had a question that while the transition.cancel() is at work, and the one of the transitions completed at that point, it might end up executing the transition contained inside the onComplete() function. Just to be on the safer side, as I can’t be sure when lots of transitions are at work.

@Xedur,

When I first read the OPs question, I took it to mean there was some confusion about one or two possible cases.

Confusion Case 1

  • Question : Does or does not cancelling a transition fire the onComplete listener?  
  • Answer :
    • I believe the answer is, “No.”
    • I suggested the OP could determine this experimentally to settle the question.

Confusion Case 2

  • Question: What happens if ‘transition.cancel()’ is called (to cancel all transitions) and a transition(s) with an onComplete listener is ending in the same frame?  i.e. Does the onComplete fire?  Because the onComplete in the OPs question is another transition, this raises the real issue of a possibly missed and uncancelled transition. 
  • Answer Part 1:  This is a black-box question.  i.e. Not knowing what the code looks like (Corona internals) it is hard to definitively and satisfactorily answer this question.  The reason this is hard to know is, one could call the function in any of many places:
    • in an enterFrame() listener
    • in a collision listener
    • in a timer
  • Answer Part 2: I think that in this case, the onComplete will fire.  i.e. The transition just completed before the beginning of this frame so the on Complete is scheduled.  AFAIK scheduled event responses do not get removed from the current frame queue. 
  • Answer Part 3: When I am faced with a issue like this, where timing and flow control is absolutely critical, I use a flag to further protect myself AND/OR I used a deferred cancel (one frame later).

You could suss out the above question experimentally, but it would be more work.

Frankly, it would be wonderful to know the processing order Corona follows each frame when it handles:

  • enterFrame listeners()
  • timers()
  • collision listeners
  • … and the zillion other listeners

My sense is, the list really defaults to a common enterFrame() list where different categories of event type are stacked into the list in a known order, but I may be wrong.  I look forward to the day I can look at the source code to work this out.

Thank you, Ed. This really helped clear my confusions :smiley:

I think your actual question should be, “When I cancel a transition, does onComplete() get called?”

If not, then you don’t have to cancel twice.

If so, then you do.

You can determine this experimentally.

Tip: You mention an infinite timer.  These are problematic.  You should reconsider that choice or be sure you can pause and/or that timer when needed.

Why?  Well, if you pause or cancel all transitions, then the timer trips and creates a new transition, it will not be paused.

Yea, roaminggamer . I have created a table to hold the references of all those infinite timers. So I go in this order:-

  • I pause the timers.

  • pause the transitions

  • remove the enterFrame events

  • pause the transitions again.

I read a forum post somewhere to pause/cancel transitions twice. I can’t seem to locate that post again.

So to be on the safer side, I wish to pause/cancel transitions twice. Is there any side effects to it. 

I don’t think there will be any negative side-effects.

Sure then, thanks for clarifying roaming gamer. I was going through your composer module on github. Its really helpful in clarifying some of the doubts I had.

@Quitalizner,

Hi.  I have two random question:

  1. What is your native language?

  2. Did you use a translator to post you comments/questions?

I am asking this purely out of curiosity and to learn something.  I have noticed that certain writers use the word ‘doubt’ when the grammatically correct word is ‘question’.

I have seen this for various languages and I am trying to form a mental map (if you will) correlating common mistakes to OPs native language.  I am a language lover and enjoy working out little puzzles like this.

PS - If your native language is English, this will be even more fascinating, as it may indicate external influences to your word choices or a change in the language itself.  However I doubt this, no pun intended. :slight_smile:

d24a49344c09812a55e7aeb60a4d516d.jpg

Sorry for jumping in here, but after I read these posts I only got confused and I’d like to make sure I didn’t confuse myself too profoundly.

For what reason would you ever need to cancel a timer or a transition twice? Sure, there won’t be any problems with double pausing, but why would this be needed in the first place? Am I just confused with the idea of zombie transitions with onCompletes jumping out of the woodwork or should I just go back to enjoying my tea, being happy to just cancel everything once like I’ve always done? :smiley:

@roaminggamer.

It’s funny that you ask that question. I find myself in confusion sometimes, whether to use the word doubt or question. Thanks for clearing this for me.

Yes, my native language isn’t English. But English has been my second language. I didn’t pay much attention while learning grammar in school, I’m repenting for that now.

@XeduR

I had a question that while the transition.cancel() is at work, and the one of the transitions completed at that point, it might end up executing the transition contained inside the onComplete() function. Just to be on the safer side, as I can’t be sure when lots of transitions are at work.

@Xedur,

When I first read the OPs question, I took it to mean there was some confusion about one or two possible cases.

Confusion Case 1

  • Question : Does or does not cancelling a transition fire the onComplete listener?  
  • Answer :
    • I believe the answer is, “No.”
    • I suggested the OP could determine this experimentally to settle the question.

Confusion Case 2

  • Question: What happens if ‘transition.cancel()’ is called (to cancel all transitions) and a transition(s) with an onComplete listener is ending in the same frame?  i.e. Does the onComplete fire?  Because the onComplete in the OPs question is another transition, this raises the real issue of a possibly missed and uncancelled transition. 
  • Answer Part 1:  This is a black-box question.  i.e. Not knowing what the code looks like (Corona internals) it is hard to definitively and satisfactorily answer this question.  The reason this is hard to know is, one could call the function in any of many places:
    • in an enterFrame() listener
    • in a collision listener
    • in a timer
  • Answer Part 2: I think that in this case, the onComplete will fire.  i.e. The transition just completed before the beginning of this frame so the on Complete is scheduled.  AFAIK scheduled event responses do not get removed from the current frame queue. 
  • Answer Part 3: When I am faced with a issue like this, where timing and flow control is absolutely critical, I use a flag to further protect myself AND/OR I used a deferred cancel (one frame later).

You could suss out the above question experimentally, but it would be more work.

Frankly, it would be wonderful to know the processing order Corona follows each frame when it handles:

  • enterFrame listeners()
  • timers()
  • collision listeners
  • … and the zillion other listeners

My sense is, the list really defaults to a common enterFrame() list where different categories of event type are stacked into the list in a known order, but I may be wrong.  I look forward to the day I can look at the source code to work this out.

Thank you, Ed. This really helped clear my confusions :smiley: