# Is there any master be good at Actionscript in Flash ?

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

## 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?

• 9
• 13
• 41
• 15
• 12