Transition/Easing 2.0?

It is worth mentioning here what happened to my code:

Two transitions set to start and end at exactly the same time, do not really end at the same time.  So if you rely on synchronising several transitions and (say) removing all objects after one of the transitions has finished, most likely you will get an error full of question marks.  Easy way around: trigger the callback using a slightly slower transition (say 10ms). 

Any sort of bounce transition definitely has an issue, and code within the transition’s onComplete gets repeated such as below.

    transition.to(endText,{time=1000,alpha=1,xScale=1,yScale=1,transition =easing.outBounce,onComplete=function()

        print(“ended endText bounce”)

    end})

Above code ends up printing “ended endText bounce” TWICE! Umm, WTH…

Seriously, i think if you guys haven’t fixed all the bugs in transitions2.0 then please put back 1.0 or something because we need to use the builds later then 1206 since other bugs were fixed, however, we definitely can’t submit or even trust the functionality of our code anymore with transitions2.0.

Hi @jacques1,

I just tested your exact code example in build #1219. It prints the ending message just once, and the bounce effect appears just fine. Not sure which build you’re using, but it works for me in #1219.

Best regards,

Brent

OSX: 10.8.5

Corona SDK 2013.1219

I can confirm Brent’s observation that it only prints the ending message once.

I used this code:

local endText = display.newText("This is some text", 10, 10, native.systemFont, 12); endText.alpha = 0; endText:scale(0, 0); transition.to(endText,{delay=1000, time=1000, alpha=1, xScale=1, yScale=1, transition=easing.outBounce, onComplete = function() print("ended endText bounce") end});

You’re both right, I also tested stand-alone and it works fine. I also re-tested inside my code and it does still happen but not all the time, I noticed it only happens when the endText (which is an image in my code) somehow gets displayed (what appears to be duplicated on itself) as it is transitioning in scale. The problem could be other transitions before or after but it’s too complicated to get into here as there’s +25,000 lines of code.

Afraid I can’t give much more info to solve this other then this weird ‘duplicated code effect’ sporadically occurs after a transition’s onComplete happens on most of my transitions now. Appreciate the help anyways.

Will await the general fix for transitions2.0 and hopefully all my other transition2.0 woes will disappear too.


Okay checked another part (same duplicate problem), also tested it stand-alone and this one does seem to print the text in duplicate. Perhaps I’m doing the code wrong somehow?

local halfW = display.viewableContentWidth / 2

local halfH = display.viewableContentHeight / 2

local satellite=display.newGroup();satellite:translate( halfW, halfH)

sattxt=display.newText(satellite,“INITIATING SATELLITE LINKUP”, 0, 0, native.systemFont, 20)

sattxt.x=0;sattxt.y=0

sattxt.anime=transition.to( sattxt, { time=1000, alpha=0, transition=easing.continuousLoop,iterations=-1 } )

local yyLine=display.newLine(satellite,-halfW,0,halfW,0);yyLine.y=0;yyLine.width=2;yyLine.alpha=1

yyLine.anime=transition.to(yyLine,{time=500,y=halfH,onComplete=function()

    transition.to(yyLine,{time=500,y=-halfH,onComplete=function()

        transition.to(yyLine,{time=1000,y=0,transition =easing.outBounce, onComplete=function()

            if sattxt.anime~=nil then transition.cancel(sattxt.anime);print(“sattxt.anime cancelled”) end

        end})

    end})

end})

Help would be appreciated :slight_smile:

@jaques, I had exactly the same problem: lots of code and sporadic issues.  I managed isolate the problematic module and it turned out to be a synchronisation issue.  If you rely on one transition calling a function that erases some objects and these objects are being transitioned still, you might have issues ===>>> even if those transitions are supposed to start and end at the same time <<<===.  If you are synchronising transitions to end at the same time but one only is calling an onComplete function, make sure that this “master transition” ends 10 milliseconds after the others.  It worked for me and, however a long-shot, it might work for you.  In your case you have a duplicate object, so this one might still be around when you clean the scene or remove the object without cancelling the transition first.  I seem to remember that there is a new API that can tell you if an object is transitioning or not.  

I would love to try and reproduce the issue but I am a bit stretched at the moment.

Hope this helps.

@jacques1 

I managed to replicate your issue with the code you submitted.

I traced it to “transition.cancel(sattxt.anime);”.

if you replace that statement with the code below, it’ll only fire once.

timer.performWithDelay(10, function() transition.cancel(sattxt.anime); end);

As paolo mentions above, there seems to be a timing issue…

Ok thanks for the help guys but its a bit of a weird  stop-gap measure.

So to confirm, if i set sattxt.anime as a transition and that transition ends, is sat txt.anime set to nil or not?

Still doesn’t quite explain the duplicate occurring, however i definitely agree there is some sort of timing issue with the new transition2.0.

I tried your suggestion with a delay of 1 instead of 10 and still works so…fingers crossed on a fix in the next build. Adding a 1 or more milisec delay reminds me of the issues devs face with box2D implementations too.

@jaques, @brent and @ingemar: it could be as simple as a numerical approximation issue in the transitions library.  Say that you split time steps and such time steps are approximated e x decimal place, then you then add them up you might find that ending times are slightly different and 0 becomes 0.1233322e-5.  That might be the bug.  So you probably need to do a time check ===> at the beginning of your transition, during whatever set-up phase you have <===.  For example add back all times and see if you get the same number as (endTime - startTime) as specified by the user.  Or even better, change start and end times to be perfectly divisible by 30 and 60 (the standard frame rates supported and used).  Just shooting in the dark here…

@jacques1

You have to nil the variable yourself.

Letting the transition end by itself, or calling transition.cancel(sattxt.anime) will not set sattxt.anime to nil.

sattxt.anime is a lua table, and I don’t think there’s an official way to test if a transition has completed or not.

@ingemar, yup i usually setting anything to nil once i cancel or remove them. Adding…

sattxt.anime=nil

in the code we were discussing prevents the…

 if sattxt.anime~=nil then transition.cancel(sattxt.anime);print(“sattxt.anime cancelled”) end

code line from repeating but a simple print statement within the tranisition’s onComplete still is repeated.

Your timer.delay was a good solution and prevented errors but not practical to do that for every transition call.

Nevermind hopefully if they fix the ‘page not found’ for the new build 1225 then their fixes will resolve all our headaches.

Yeah. The timer thing is a bit of a hack in this case.

I don’t see any logical reason why cancelling a transition on a completely different object with unrelated transitions should affect the current one. It must be some internal bug.

First I thought that belonging to the same display group might trip Transitions 2.0 up, but putting them in separate groups gave the same results…

BTW I can download the daily builds again. They have fixed the ‘Page not found’ error

I still get page not found whether in safari or firefox. Perhaps its a country based issue as I’m over here in Asia. So you’re able to DL build 1225?

So am I :D   (I’m in Korea)

Looks like there are some propagation delays. I had the same issues, but was able to download about an hour ago…

Give it a bit of time, guys. The propagation can take a while sometimes.

alex

Hi Paolo,

The issue should be fixed in 1225. Could you please confirm?

Thanks,

alex

It looks like the double call to onComplete has been fixed with build #1225 :slight_smile:

For those who can’t download the latest daily build, try logging off the Corona website, then log back on and retry downloading again.

@alexf – i am somewhere else entirely now, cannot download or even access my code.  untested pseudo code for my problem is:

local circle1 = display.newCircle(200, 200, 10)

local circle2 = display.newCircle(200, 200, 10)

local function removeObjects()

        display.remove(circle1); circle1 = nil

        display.remove(circle2); circle2 = nil

end

transition.to(circle1, "time = 500, xScale = 2, yScale = 2, onComplete = removeObjects ")

transition.to(circle2, “time = 500, xScale = 2, yScale = 2”)

It should throw an error with older version and not with 1225.  if that is the case, consider it solved.  and thanks a lot for looking into this.