Home arrow Articles arrow Flash arrow Collision detection & bouncing part 2: actionscript examples of collision detection
Collision detection & bouncing part 2: actionscript examples of collision detection Print E-mail
Tuesday, 06 June 2006
Article Index
Collision detection & bouncing part 2: actionscript examples of collision detection
demo 1: A ball hitting a wall
demo 2: collision detection before the ball hits the wall
demo 3: the ball approaching the wall at a sharp angle
demo 4: the ultimate ball-hits-wall algorithm
demo 5: a polygon hitting a wall
At a jiu-jitsu seminar I asked a Japanese grandmaster which was the preferred way  to do a certain wrist lock. He answered: "Life has many ways, choose one".
The same wisdom applies to collision detection. There are many ways to implement the intersection-of-line-segments-formula I explained in the first article. In this article we'll explore some algorithms in Flash to detect collisions of a moving circle or polygon enclosed by another polygon.

I assume that you have at least basic knowledge about vectors. I have written a vector actionscript class, which contains most of the vector operations you'll ever need. Here it is, free of charge. The source code is sufficiently documented.



Comments
thank you so much for this!!
i have been searching for weeks to find this

  Posted by Roman Vaughan, Whose homepage is http://smartie.awardspace.com/ on Thursday, 03 August 2006 at 7:21

This is the best collision detection explanation and example I have seen for flash yet! Much better than using a simple hitTest or whatever, thanks so much!
  Posted by Vince, Whose homepage is http://kamazar.com on Sunday, 07 January 2007 at 12:56

There are some good flash tutorials dealing with collisions on www.tonypa.pri.ee. The website should provide some extra reference material for those interested.
  Posted by Mike Hamman, on Friday, 11 April 2008 at 4:06

Thanks, this is the most on to it explanation I've had. Will allow for some truly dynamic realistic collisions. Are you still building on this?
  Posted by Alexis, Whose homepage is http://www.joomlabear.com on Sunday, 29 June 2008 at 5:22


 1 
Page 1 of 1 ( 4 comments )
©2005 MosCom

Add your comments to this article Collision detection & bouncing part... ...

Name (required)

E-Mail (required)
Your email will not be displayed on the site - only to our administrator
Homepage

Comment