Transitions with 0 time

What are the side effects of doing a transition with a time of 0? Does it just set the thing you asked it to transition and call the onComplete handler? Or does it go through various other stages?

ie. if you do

[code] – in some function

  transition.to(anObject,{alpha=1,time=0})

end[code]

Does (in this example) the alpha of anObject become 1 before or after end and what sort of things would you have to be careful to avoid doing to it between calling transition and the end of the chunk it was in?

In all likelihood, that will take one frame to complete.  

You can easily test this:

local obj = display.newCircle(10,10,10) function obj.onComplete( self ) print("In onComplete() ", self.alpha, system.getTimer()) end print("Before call: ", obj, alpha, system.getTimer()) transition.to( obj, { alpha = 0, time = 0, onComplete = obj } ) print("After call: ", obj, alpha, system.getTimer())

This will probably print, something like (but you should run the code and check):

Before call: 1 \<time1\> After call: 1 \<time1\> In onComplete() 0 \<time2 == time1 + ~33.33 or 66.66\>

However, if you get this,

Before call: 1 \<time1\> In onComplete() 0 \<time1\> After call: 1 \<time1\>

then you’ll know that transition w/ 0 time executes immediately.  I still think it is the prior though.

I’m curious why you would want to do this?

It is, thank you :slight_smile:
 

I wouldn’t, I’d check if the time I was asked to do something was 0 and if it was do it now.
The code in question is inside scrollview and tableview widgets, doing any sort of scrollto with a time of 0 just passes the time onto transition and leaves that to deal with it, ie. a time of 0 isn’t 0 it’s “very short, approximately 0ish depending on how many other things happen between now and the next frame but absolutely not before the end of the current chunk”

In all likelihood, that will take one frame to complete.  

You can easily test this:

local obj = display.newCircle(10,10,10) function obj.onComplete( self ) print("In onComplete() ", self.alpha, system.getTimer()) end print("Before call: ", obj, alpha, system.getTimer()) transition.to( obj, { alpha = 0, time = 0, onComplete = obj } ) print("After call: ", obj, alpha, system.getTimer())

This will probably print, something like (but you should run the code and check):

Before call: 1 \<time1\> After call: 1 \<time1\> In onComplete() 0 \<time2 == time1 + ~33.33 or 66.66\>

However, if you get this,

Before call: 1 \<time1\> In onComplete() 0 \<time1\> After call: 1 \<time1\>

then you’ll know that transition w/ 0 time executes immediately.  I still think it is the prior though.

I’m curious why you would want to do this?

It is, thank you :slight_smile:
 

I wouldn’t, I’d check if the time I was asked to do something was 0 and if it was do it now.
The code in question is inside scrollview and tableview widgets, doing any sort of scrollto with a time of 0 just passes the time onto transition and leaves that to deal with it, ie. a time of 0 isn’t 0 it’s “very short, approximately 0ish depending on how many other things happen between now and the next frame but absolutely not before the end of the current chunk”