Jump to content
Search Community

Overwrite not working when using strings [SOLVED]

dmennenoh test
Moderator Tag

Recommended Posts

I have two tweens on an object in CS4 that do a rotate on X by 180º. When I use strings like I want, so the object rotates from wherever it is, the overwrite:0 is not working. I do:

 

TweenLite.to(myObject, .5, {rotationX:"180"});

 

and then:

 

TweenLite.to(myObject, .5, {rotationX:"180", overwrite:0});

 

In the second tween, it just goes from wherever the first one is, regardless of the overwrite setting, causing the object to 'land' at an incorrect angle - ie not 360º rotated. I've had to resort to using hard coded values for the rotations instead of strings like I was hoping for.

 

Seems a bug to me.

Link to comment
Share on other sites

Nope, it's definitely not a bug. I think you might be misunderstanding how a tween works and when the starting values are populated. When a to() tween actually begins playing (after any delay), it will tween the property from wherever it is at that moment to whatever you defined. So consider the following code:

 

TweenLite.to(myObject, .5, {rotationX:"180"});
TweenLite.to(myObject, .5, {rotationX:"180", overwrite:0});

 

Both tweens will start at the same time. So let's say the rotation is currently 0. The first tween will start and say "okay, add 180 to whatever the current value is over the course of 0.5 seconds. Go!" And it applies the very first increment (so if you were using a linear ease, and the first render happens at 0.02 seconds, it'll set the value to 3.6). then the second tween starts and say "okay add 180 to the current value which is 3.6....) See what I mean? When the 2nd tween finishes, it'll be at 183.6.

 

Your code was assuming the second tween would look at the first one, immediately fastforward that tween to its end, and add the relative value to that. See the logic flaw? You really shouldn't have two tweens of the same object affecting the same property at the same time anyway. Did you want to sequence them? If so, make sure you add a delay to the second tween. Or use the new TimelineLite or TimelineMax class in v11 to set up a whole sequence. http://blog.greensock.com/v11beta/

Link to comment
Share on other sites

Your code was assuming the second tween would look at the first one, immediately fastforward that tween to its end, and add the relative value to that. See the logic flaw? You really shouldn't have two tweens of the same object affecting the same property at the same time anyway.

 

Actually, I thought with overwrite set to 0, the first tween would be allowed to end before the second one started. I just gave the two together like that as an example - they 'can' happen together in a game I'm building - when an object begins flipping, it's possible to click another object... when that happens I want the first object to complete it's flip, then flip again to go back to its original position. I see the flaw now, yes. Thanks for the clarification. Funny, I've been using TweenLite for a couple years and never ran into this.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...