Hello.
I am working on a baseball game. I got the hitting part down. But it just goes to a random spot. Is it possible to code the game to make it glide to the spot where it is, like a baseball? So let's say this:
The player hits the ball. There's 2 variables with random numbers for x & y. The ball is hit and it goes towards the direction of the variables. It then stops at the correct place.
Here's my code:
ActionScript Code:
onClipEvent (load) {
rad += (k/180)*Math.PI;
_root.hitball._x -= Math.cos(rad);
_root.hitball._y -= i;
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
var randomNumber = Math.cos(rad)+Math.floor(500)*Math.random();
var randomNumber2 = Math.floor(453.6)*Math.random();
}
onClipEvent (enterFrame) {
rad += (k/180)*Math.PI;
_root.hitball._x -= Math.cos(rad);
_root.hitball._y -= i;
_root.hitball._x = randomNumber;
_root.hitball._y = randomNumber2;
}
Thanks.