Finding the consistant slope
i trying have ball move 1 side of stage exact x , y points on other side of stage. example, let's ball's x =25 , y=80, , point want move @ point x=350 , y=100. if want ball travel @ consistant speed (doesn't matter), how this?
does make sense? it's simliar movie clip following mouse, sort of...help please.
does make sense? it's simliar movie clip following mouse, sort of...help please.
is speed fixed? if not, had change x , y position constantly, guess wouldn't have asked then.
so when it's fixed, need know distance start end point. know both points, can use
distance = math.sqrt( math.pow(startpoint._x - endpoint._x, 2) + math.pow(startpoint._y - endpoint._y, 2) );
this gets length of line between points in pixels.
then can time take go distance in given speed:
time = distance / speed;
now if speed 50 pixels per second, time in seconds, , 5 seconds. take animation speed (e.g. framerate, if animate onenterframe), , number of animation steps take reach end:
steps = time * animation_speed
finally total distances x , y, endpoint.(x | y) - startpoint.(x | y), , divide steps number distance each step:
stepx = (endpoint._x - startpoint._x) / steps;
stepy = (endpoint._y - startpoint._y) / steps;
now have distance each animation step , can use them in animation move ball given speed.
hth,
blemmo
![](/webforums/forum/images/i/expressions/face-icon-small-wink.gif)
so when it's fixed, need know distance start end point. know both points, can use
distance = math.sqrt( math.pow(startpoint._x - endpoint._x, 2) + math.pow(startpoint._y - endpoint._y, 2) );
this gets length of line between points in pixels.
then can time take go distance in given speed:
time = distance / speed;
now if speed 50 pixels per second, time in seconds, , 5 seconds. take animation speed (e.g. framerate, if animate onenterframe), , number of animation steps take reach end:
steps = time * animation_speed
finally total distances x , y, endpoint.(x | y) - startpoint.(x | y), , divide steps number distance each step:
stepx = (endpoint._x - startpoint._x) / steps;
stepy = (endpoint._y - startpoint._y) / steps;
now have distance each animation step , can use them in animation move ball given speed.
hth,
blemmo
More discussions in ActionScript 1 and 2
adobe
Comments
Post a Comment