views:

271

answers:

1

What I want to do is rotate the object and have its collision box rotate with it. I want the rectangle to rotate so it looks like a diamond and have one of its sides hit the object in a per pixel fashion. From my reading of some books and websites it seems that normal rectangular collision and hitTestObject collision won't do for this problem. I have searched high and low and want to know if anyone has a solution to hit detection with moving and rotating objects. Here is my current collision code with rectangles

colboxrect = colbox1.getRect(this);
robotrect = robot1.getRect(this);
if(robotrect.intersects(colboxrect))
{
   velocity *=-1;
}

What I want to happen is when it collides the robot will bounce off of the box. It works but only when it hits it head on. I want it to rotate and be able to hit. I am looking for the flash equivalent of this basically. http://creators.xna.com/en-US/tutorial/collision2dperpixeltransformed

How can I accomplish this?

A: 

You can use BitmapData's hitTest() method for that. Here a few articles on that by Adobe's Mike Chambers:

The pixel perfect technique is around for some time. Grant Skinner wrote an as2 version in the flash 8 days. There are ports to as3 obviously.

Corey O'Neil wrote the Collision Detection Kit, you might want to have a look.

HTH, George

George Profenza