View Full Version : help about collisions....
bluemagica
03-15-2008, 04:22 PM
It is best to say here, that i am using as2 and have no idea about as3... now, the most common method to detect collision is using hitTest , but this takes the entire bounding box into consideration, thus making...err...rectangular collisions, not collision between actual shapes. So how do i check for collision between two shapes? at many places i have seen that "you should detect complex collision using mathematics", and they only give example of a square or circle as complex shape.....achieving this for irregular shapes seems quite hard, and it seems almost impossible for a animation sequence....so whats the walk-around?
andrewProgrammer
03-29-2008, 06:59 PM
The hitTest uses a bounding box collision, but there is another way to use it. What it is is "movieClip.hitTest(x, y, true)". The "movieClip" is the movie clip that will be the collision-e (the one that gets hit). Inside of the "()" there is "x" which is the x-point in which will hit the collision-e. The "y" is the y-point in which will hit the collision-e. I don't know why there is the "true", but you have to have it or else it won't work. When you put the x and y together it makes one point. This point will be tested if is being touched by the EXACT shape of the collision-e (no matter how abnormal the shape).
I hope that this helped you. I have been coding for 2 years, and I have'nt been able to find a better collision test.
bluemagica
03-30-2008, 03:48 AM
No andrew that isnt quite the solution i was looking for, as this method is for point vs shape, i want shape vs shape. bitmapdata.hitTest seems to be a potential solution to my work, but still, as far as i see, there is no shape vs shape collision in flash....
bluemagica, if you don't want to use hitTest it's up to you but then you just have to write your own collision detections and I hope for you that you have a good understanding of this. if you don't, use hitTest and say thank you for andrewProgrammer advice instead of just refusing and being rude.
ASWC: That wasn't rude, that was a correction.
bluemagica: The reason the usual answer is vague stuff about detecting the collision through math is that there isn't one simple solution. The bitmapdata thing sounds promising. I haven't tried it, though, so I guarantee nothing.
8bitjeff
03-31-2008, 06:47 AM
BitmapData will definitely do the job. It eats up a little more process time, but it works great. I have a tutorial on using it in AS2. You can read it here: http://www.8bitrocket.com/newsdisplay.aspx?newspage=2551
I have a new one on doing it in AS3 here: http://www.8bitrocket.com/newsdisplay.aspx?newspage=9947
And a slightly easier one that is a little older (still in AS3): http://http://www.8bitrocket.com/newsdisplay.aspx?newspage=6421
I hope this helps. It really isn't that difficult once you have all of your graphics in BitmapData objects.
bluemagica
03-31-2008, 12:24 PM
Thanks to both of you, rrh, and 8bitjeff....i havent learned as3 yet, but the as2 one is pretty helpful...it seems i was in the right direction afterall, and thanks to your help i can make my game possible. Thanks again....
And ASWC, do you really consider reclarifying my question as rudeness?I was only telling andrew what i need actually, cause i believed, i might not have made myself clear in the first post.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.