Jump to content
  • Advertisement
Sign in to follow this  

Is there any master be good at Actionscript in Flash ?

This topic is 2424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Collision Detection is very important to the Flash!
Now , i have been making a game about basketball,but there is a big skill problem blocked my game development which is about the collision detection algorithm of two balls.
I have defined the name "ball" and "balll".They are all from Ball Class.Ball Class have got the Attribute ,such as ball.vx,ball.vy,ball.radius,ball.v;

Here is my code

sina = (ball.y - balll.y)/(ball.radius + balll.radius);
cosa = (ball.x - balll.x)/(ball.radius + balll.radius);
distance = Math.sqrt((ball.x - balll.x)*(ball.x - balll.x) +(ball.y - balll.y)*(ball.y - balll.y));
if (distance <= (ball.radius +balll.radius))
v = Math.sqrt(ball.vx * balll.vx + ball.vy * balll.vy);
ball.x = balll.x+cosa*(ball.radius+balll.radius);
ball.y = balll.y+sina*(ball.radius+balll.radius);
ball.vy *= 0.8;
ball.vx *= 0.4;
ball.vx = (v * cosa);
ball.vy = (v * sina);
balll.vx = -(v * cosa);
balll.vy = -(v * sina);

Now , if the speed of ball is so fast , two ball will l overlapped together and they will not move or move slowly.How can i solve this problem?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!