Jump to content
Search Community

easing method question

TeamChuck test
Moderator Tag

Recommended Posts

I've been going through the ease visualizer trying to figure out which tween would work best for what I need. This has probably been an oft answered question but I haven't been able to find anything.

 

I'm throwing an object. So the ease I would need would start off at max speed, decrease to nearly zero in the middle and then increase to the max speed. For an object going straight up and down, Sine.easeOut(up) and Sine.easeIn(down) simulate the correct effect but I'm having the object follow a bezier path. Is there a way to create a custom ease method or can the ease method be replaced half way through(although I don't see this working)?

Link to comment
Share on other sites

Hey, thanks for your reply. Trying to create my own custom ease but having some difficult.

 

import com.greensock.easing.CustomEase;
var myEase:Function = CustomEase.create("myCustomEase", [{s:0,cp:0.51,e:0.76},{s:0.76,cp:1.01,e:1}]);
TweenMax.to(bBall, 2, {bezierThrough:[{x:pX, y:pY},{x:eX, y:eY}], ease:myEase.ease});

 

Gives me these errors:

Line 1 -- 1172: Definition com.greensock.easing:CustomEase could not be found.

Line 2 -- 1120: Access of undefined property CustomEase.

Line 3 -- 1119: Access of possibly undefined property ease through a reference with static type Function.

 

I've also been trying to use .parseBeziers but haven't been able to.

 

TweenMax.parseBeziers(bBall)

I think my understanding of this is off though, what parameters do I pass through? Do I give it the start point, end point and control point x/y values?

Link to comment
Share on other sites

Gives me these errors:

Line 1 -- 1172: Definition com.greensock.easing:CustomEase could not be found.

Line 2 -- 1120: Access of undefined property CustomEase.

Line 3 -- 1119: Access of possibly undefined property ease through a reference with static type Function.

That's because you don't have the CustomEase class I bet. It's only for Club GreenSock members (http://www.greensock.com/club/).

 

As for drawing a line through a bezierThrough, were you just planning on using an onUpdate in the tween and inside that onUpdate do a lineTo() to incrementally draw the line? That can work, but make sure your frame rate is adequate to avoid any jagged lines. That's basically what I do in the Ease Visualizer tool.

Link to comment
Share on other sites

I honestly wasn't sure how I was going to trace the path the object takes. I've been trying to figure out a way of using curveTo() but the more I try and the more I search for a solution, the more I'm realizing that unless the start and end y values are the same, its next to impossible to make it accurate.

 

What I've done so far, but it makes a jagged line, is to use a delayedCall and run the same function over and over taking the objects current position and using lineTo until the object comes to a rest.

 

------

 

So as I was writing this I started looking up onUpdate and that does exactly what my delayedCall was doing. Only better. I'm really wishing I had have found the onUpdate special property...oooooh...about eight hours ago. One of those days.

Link to comment
Share on other sites

I have another question regarding the bezierThrough. I'd like to update the ending location. I know my syntax is wrong though:

 

TweenMax.updateTo(bBall,{bezierThrough:[{x:pX, y:pY},{x:eX, y:eY}],false)

 

eX and eY being my end X and end Y values.

Link to comment
Share on other sites

Darn...that would have been pretty cool.

 

I've been going over some of the plugins you offer that you get for being part of the GreenSock club, I think I'm going to break down and get the middle one so I can have the two physics plugins and the custom ease.

Link to comment
Share on other sites

Actually, if you wouldn't mind if I picked your brain some more, this could seal the deal.

 

With the physics2D and the physicsProps plugin...this question is for either one...is there a way of tracing the current velocity and angle of whatever object is being tweened at any given time? If that's the case I'm sold.

 

I'm trying to build a basketball game. It's the first game I've attempted, and the first time since highschool(2001) that I've had to do any physics calculations. Simple collision detection, it's either a vertical or horizontal obejct that is collided with.

Link to comment
Share on other sites

No, you can't get the current acceleration/velocity value from the plugin or tweening engine directly - it is built for maximum efficiency and minimal size. You can certainly use an onUpdate to figure out those values for yourself if you prefer, but I'd highly recommend picking up Keith Peters' book ActionScript Animation because it'll walk you through doing pretty much exactly what you're talking about manually. The nice thing about the TweenLite/Max stuff is that you can put 'em into TimelineLite/Max instances, reverse(), pause(), resume(), restart(), skip to any point in the animation, etc.

 

Good luck with your project.

Link to comment
Share on other sites

  • 6 months later...

Can anyone help with the lineTo onUpdate method that was discussed earlier?

 

i'd like to draw a line through a curve that i'll create using customEase, this is what i have so far, can someone advise please?

 

import com.greensock.easing.CustomEase;

import com.greensock.TweenLite;

 

this.lineStyle(1,0xFFFFFF,100);

this.moveTo(0,0);

 

var myEase:CustomEase = new CustomEase("myCustomEase", [{s:0,cp:0.502,e:0.752},{s:0.752,cp:1.002,e:1}]);//do this only once for each custom ease you want to create.

 

function doStuff() {

TweenLite.to(test,1,{_y:"400", ease:myEase.ease, onUpdate:doUpdate});

}

 

//this is where i get stuck!

function doUpdate() {

this.lineTo(pointsHere, here, andHere???);

}

 

this.onMouseDown = function() {

doStuff();

};

Link to comment
Share on other sites

i'd like to draw a line through a curve that i'll create using customEase, this is what i have so far, can someone advise please?

Could you explain what you mean by this? A CustomEase is just for easing the rate of change in your property tweens and it has nothing to do with drawing a line through a curve. Do you have an example somewhere? I'm more of a visual person, so that'd help.

Link to comment
Share on other sites

The BezierPlugin has a way of doing that sort of thing - you can feed it points and it can spit back data that you feed to Flash's curveTo() to draw curved lines through the points. That's basically what I do in the interactive demo for bezierThrough (see the Plugin Explorer).

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