Jump to content
Search Community

Discontinuous Tweens?

robertnyc test
Moderator Tag

Recommended Posts

What's the best way to do a discontinuous tween?

 

This arises in a project I'm working on where I need to rotate an object around a circle -- and also rotate the object to always face the center. Due to the geometry there was a case where the range was discontinuous and I got a situation like this

 

			_nuRotation = _angleInDegrees < 0  || (_angleInDegrees >0 && _angleInDegrees <=90)? _angleInDegrees +90 : _angleInDegrees -270;

 

Don't worry about what it means -- the point is that there was a break, as there must be, in the circular degrees. Now in this incarnation I'm moving the mouse and rotating everything based on that. What I'd like to do is programmatically move things -- and use TweenMax to tween the angle and then set everything based on that. (Note I can't simply use rotation, as it's an object rotating around something, etc etc).

 

How would I do this? I could use onUpdate during the tween to check and "jump" the tweening values, but if I'm one tween update behind or ahead, I could have the object flying to the opposite side of the circle, then back. Is there anyway in TweenMax to specify something like

 

tween from a to b then from c to d

in one tween. I suppose you could set up two tweens, but looking for simplicity?

Link to comment
Share on other sites

I read your description a few times but didn't quite understand your goal. Here are a few ideas that may or may not relate to your question:

 

1) If you want to sequence two tweens (tween a to b, then c to d) and control the sequence as a whole, that's what TimelineLite is perfect for.

 

var tl:TimelineLite = new TimelineLite();
tl.append( TweenMax.fromTo(mc, 1, {rotation:a}, {rotation:b}) );
tl.append( TweenMax.fromTo(mc, 1, {rotation:c}, {rotation:d}) );

 

2) If you're currently using your mouse as the focal point of your rotations and you want to shift to using TweenMax, you could just tween a Point object in place of the mouse:

 

var focalPoint:Point = new Point(0, 0);
TweenMax.to(focalPoint, 1, {x:200, y:300, onUpdate:updateRotations});
function updateRotations():void {
   for (var i:int = 0; i         //calculate all your custom rotations in here
   }
}

 

If these don't help, please provide a visual example of what you're after - sorry, I'm quite sleep-deprived so you may have described things fine and my brain is just slow today.

Link to comment
Share on other sites

Thanks -- I'm somewhat sleep deprived today as well so perhaps I was unclear. I think it must be something like what you did in the internals of CirclePath2DPlugin -- simply that as you move around a circle the angle will jump from 360 to 0, for instance, so if you're tweening from 180 to 70 you're going to have a tween from 180 to 360 then from 0 to 70; timeline sounds like a good plan.

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...