Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-02-2012, 02:12 AM   #1
Guy71173
Registered User
 
Join Date: Jun 2012
Posts: 8
Default How to Make Animation Go To Variable

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.
Guy71173 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:32 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.