aurelienRibonBackup / java-universal-tween-engine

Automatically exported from code.google.com/p/java-universal-tween-engine
0 stars 0 forks source link

repeatYoyo displays glitches when the animation is played backward #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Animate e.g. 3 Sprites along a path with a construct like this:
                Timeline timeline = Timeline.createSequence()
                .beginParallel()
                .push(Tween.to( sprite1...))
                .push(Tween.to( sprite2...))
                .push(Tween.to( sprite3...))
                .end()
                .beginParallel()
                ...
                .end()
                .beginParallel()
                ...
                .end()
                .delay(delay)
                .repeatYoyo(25, 0.5f)
                .setCallbackTriggers(TweenCallback.COMPLETE)
                .setCallback(cb)
                .start(tweenManager);

2. Everything before the animation is repeated backward works fine. When the 
animation is played backwards,  graphical glitches occur with non correct 
blitting of the sprites.
3. This effect doesn't occur if the parallel tweens are organized in their own 
timelines. Means one timeline for one sprite. The same construct without 
beginParallel() etc.

What version of the product are you using? On what operating system?
6.3.3

Please provide any additional information below.
I could make a video and send it to you, if you don't get me :).

Best regards
Ron

Original issue reported on code.google.com by isaku...@gmail.com on 3 Sep 2012 at 10:14

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I encountered this issue yesterday when fooling around with the library. After 
doing some debugging I've come to the conclusion the issue is only with the 
TimeLine class, and when the delay of repeatYoyo is set to more than 0. 

The issue occurs when the timeline is disabled(isIterationStep = false) but its 
children remain enabled. This results in interpolations when the timeline 
should in fact be waiting for the delay to be over. 

I've come up with two "solutions" to fix the repeatYoyo functionality.

1. Inside BaseTween, navigate to updateStep(), find the following code:

} else if (isIterationStep && currentTime+deltaTime < 0) {
    isIterationStep = false;
    step -= 1;
    float delta = 0-currentTime;
    deltaTime -= delta;
    currentTime = 0;
    updateOverride(step, step+1, isIterationStep, delta);
    callCallback(TweenCallback.BACK_END);
    if (step < 0 && repeatCnt >= 0) 
        callCallback(TweenCallback.BACK_COMPLETE);
    else 
        currentTime = repeatDelay;
}

delete  updateOverride(step, step+1, isIterationStep, delta);

2. this solution requires a bit more work, but it doesn't simply remove a whole 
call. 
Inside BaseTween add the following method:
    void setIsIterationStep(boolean step){
        isIterationStep = step;
    }
Inside Timeline in updateOverride() replace:
    if (!isIterationStep && step < lastStep) {
        assert delta <= 0;
        float dt = isReverse(lastStep) ? -delta-1 : delta+1;
    for (int i=children.size()-1; i>=0; i--) children.get(i).update(dt);        
    return;
   }
With:
    if (!isIterationStep && step < lastStep) {
        assert delta <= 0;
        float dt = isReverse(lastStep) ? -delta-1 : delta+1;
    for (int i=children.size()-1; i>=0; i--) {
            children.get(i).setIsIterationStep(false);
        children.get(i).update(dt);
    }       
    return;
   }

Original comment by Hmedina....@gmail.com on 26 Nov 2013 at 1:26

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
When I tried solution 1, I found that the value at the end, after the tween had 
fully run, was one step away from what it should be.

I believe the following simpler fix will sort that...

Instead of deleting the line, change it to updateOverride(step, step, 
isIterationStep, delta);

i.e. Remove the +1 from the second argument.

Original comment by ClimberP...@googlemail.com on 7 May 2015 at 9:39