This content has been marked as final.
Show 3 replies

1. Re: Finding the consistant slope
blemmo May 17, 2006 1:31 PM (in response to gregmax17)Is the speed fixed? If not, you just had to change the x and y position constantly, but I guess you wouldn't have asked then.
So when it's fixed, you need to know the distance from start to end point. As you know both points, you can use
distance = Math.sqrt( Math.pow(startPoint._x  endPoint._x, 2) + Math.pow(startPoint._y  endPoint._y, 2) );
this gets the length of the line between those points in pixels.
Then you can get the time it will take to go that distance in the given speed:
time = distance / speed;
Now if the speed is something like 50 pixels per second, the time is also in seconds, and you will get something like 5 seconds. Now take the animation speed (e.g. the framerate, if you animate with onEnterFrame), and get the number of animation steps it will take to reach the end:
steps = time * animation_speed
Finally get the total distances for x and y, which is endPoint.(x  y)  startPoint.(x  y), and divide those by the steps number to get the distance for each step:
stepX = (endPoint._x  startPoint._x) / steps;
stepY = (endPoint._y  startPoint._y) / steps;
Now you have the distance for each animation step and can use them in the animation to move the ball with the given speed.
hth,
blemmo 
2. Re: Finding the consistant slope
gregmax17 May 17, 2006 2:17 PM (in response to gregmax17)THANK YOU! 
3. Re: Finding the consistant slope
blemmo May 17, 2006 3:04 PM (in response to gregmax17)de nada.
"information not shared is lost"
don't know who said that, but it's a good statement... and true.
greets