Collision Tests
As you noticed, I’m building a small arcarde shooter in AS3 besides my daily work. It started as a small test and got me ;). In my previous post I used getObectsUnderPoint for a hittest between the shot and the enemyclips, this works fine if you don’t need a collision reaction and the clips travel at a moderade speed. Now I wanted to integrate a collision detection and reaction for the enemies and made use of some nice scripts I found out there:
A shape-based collision detection for bitmaps by Grant Skinner, since the third parameter in hitTestPoint(x:Number, y:Number, shapeFlag:Boolean) only works for vectorimages and I’m using bitmaps as graphics. A Proximity Manager. This small class comes really handy and the principle is so simple. The proximity manager splits the stage into grids and stores for every sprite in which grid they are. So you don’t need to test every sprite against all other sprites, instead you just say: “Give me all neighbours of that sprite”, which saves a lot of loops.
So I had the tools for a nice collision detection, for the collision reaction I converted a simple snooker algorithm to AS3: Snooker Balls. Watch the result:
Move your mouse over me!
19. December 2007 | Posted in Actionscript, Experiments, Flash 9


4 Comments
1. justin | 10. January 2008 at 02:20
Hi,
have you looked through here: http://lab.polygonal.de/category/actionscript/
Very nice!
2. lars | 10. January 2008 at 10:48
I know, but I didn’t want to rewrite everything, so that I could add a real physics engine ;)
3. Corey | 02. March 2008 at 02:43
Excellent site. I had the same idea of using Skinner’s Proximity class, but I’m a bit too new to programming to implement it. Would you share the source by chance?
4. lars | 03. March 2008 at 15:33
Maybe I will share the source of the game, but first it isn’t finished and I haven’t decided yet, what I will do with it ;)
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback this post | Subscribe to the comments via RSS Feed