PDA

View Full Version : perfect hitTest function


orange gold
02-03-2009, 04:41 AM
edit: before you read any further... this whole project should be done in actionscript 2

ok.. obviously as many of you know flash's hitTest function is corrupt... the purpose of this challenge is to create a hitTest that well detect hitTest down to the pixel. not just the bounding box or shapeFlag... basically anyone who wants to use the code would just copy and paste in our function at the start of their as file and then just enter in their instance names or w/e

the object of the challenge is simple... and consits of 4 mini chalenges

challenge pt.1
create a code that traces out the two objects we will be using for our hitTest

challenge pt.2
make a code to use hitTest on each pixel of thoose two traced out actionscript objects of our original object

challenge pt.3
have the tracings move with the objects not only x and y scale but click and drag... size increase rotation xscale if visibility is off hitTest goes off etc.

challenge pt.4
simplify all the code as small as possible and give all the objects varable names so that the code starts out

variableobject1 = //"name of your object here"
variableobject2 = //"name of your other object here"
//main code goes here


that way anyone can copy the final hitTest code into their actionscript file and ust fill in thoose 2 variable names without the troubles of flash's not fully functional default hitTest functions but get the full exact effect there looking for


ENJOY
LET THE GAMES BEGIN!

edit: thx for the first 2 comments on helping me fix this up ~ OG

newblack
02-03-2009, 07:44 PM
i think you might need to be more specific. what does the algorithm return? a midpoint? a collection of points that represents the entire union of the objects? a collision normal? collision detection is a huge field and solutions are application specific...

CyanBlue
02-03-2009, 07:57 PM
FYI, there are many blog posts & forum threads that talks about achieving better hitTest in Flash... For example, this one looks very promising and efficient...
http://troygilbert.com/2007/06/25/pixel-perfect-collision-detection-in-actionscript3/

And, the whole idea of this challenge is that you come up with an idea, you create one that carries that idea, and have others share what they come up with... You probably are missing first two... You really need to define more on your thoughts, as newblack mentioned, and come up with some sample of yours so that others can participate... ;)