|
TheHuckleberryWill
Guest
|
 |
« on: April 08, 2013, 05:54:00 AM » |
|
Hi guys, I would normally ask on the flashpunk forums, but they are down so....
Any, in FlashPunk I have rotated a simple Entity, (A square) by a random amount every time I add a new one.
Thing is, the hitboxes do not rotate with the graphic. Anyone know how to rotate the hitbox too?
Or, at least set the point of which the graphic rotates about.
Thanks for the help
|
|
|
|
|
Logged
|
|
|
|
|
Gregg Williams
|
 |
« Reply #1 on: April 08, 2013, 06:10:58 AM » |
|
Cheap way to get around this problem, just use bounding circles instead. If you want to do rotated bounding box collisions google OBB.
|
|
|
|
|
Logged
|
|
|
|
|
TheHuckleberryWill
Guest
|
 |
« Reply #2 on: April 08, 2013, 06:13:18 AM » |
|
Cheap way to get around this problem, just use bounding circles instead. If you want to do rotated bounding box collisions google OBB.
Erm, Im a little new to this, how would I do that?
|
|
|
|
|
Logged
|
|
|
|
|
Fallsburg
|
 |
« Reply #3 on: April 08, 2013, 06:48:56 AM » |
|
No clue if this will actually work, but here's a link on getting pixel perfect collisions in Flashpunk, which should hopefully do what you want (just make sure to make your bounding box large enough to fit all rotations inside of it). Obviously it's overkill, as opposed to something like an oriented bounding box, but it's there.
|
|
|
|
|
Logged
|
|
|
|
|
TheHuckleberryWill
Guest
|
 |
« Reply #4 on: April 08, 2013, 06:51:29 AM » |
|
No clue if this will actually work, but here's a link on getting pixel perfect collisions in Flashpunk, which should hopefully do what you want (just make sure to make your bounding box large enough to fit all rotations inside of it). Obviously it's overkill, as opposed to something like an oriented bounding box, but it's there. Nope, it doesnt...  Thanks for trying though!
|
|
|
|
|
Logged
|
|
|
|
|
Noogai03
|
 |
« Reply #5 on: April 08, 2013, 06:52:49 AM » |
|
I have no idea what Flashpunk is let alone how to fix this, but I'm just assuming the hitbox isn't an AABB - because if it is then by definition it cannot be rotated
|
|
|
|
|
Logged
|
So long and thanks for all the pi
|
|
|
|
TheHuckleberryWill
Guest
|
 |
« Reply #6 on: April 08, 2013, 06:54:36 AM » |
|
I have no idea what Flashpunk is let alone how to fix this, but I'm just assuming the hitbox isn't an AABB - because if it is then by definition it cannot be rotated
It might be.....
|
|
|
|
|
Logged
|
|
|
|
|
Noogai03
|
 |
« Reply #7 on: April 08, 2013, 06:56:40 AM » |
|
AABBs are a (relatively) easy way of doing collisions, so it's entirely possible that the hitboxes are AABBs. If they are... idk...
|
|
|
|
|
Logged
|
So long and thanks for all the pi
|
|
|
|
TheHuckleberryWill
Guest
|
 |
« Reply #8 on: April 08, 2013, 06:58:23 AM » |
|
AABBs are a (relatively) easy way of doing collisions, so it's entirely possible that the hitboxes are AABBs. If they are... idk...
Ok then, for now I will just center the hitbox on the graphic, and make the hitbox large enough for the whole thing to fit inside 
|
|
|
|
|
Logged
|
|
|
|
|
nikki
|
 |
« Reply #9 on: April 08, 2013, 07:39:28 AM » |
|
...just use bounding circles instead... Erm, Im a little new to this, how would I do that? if you have a circle for a hit'box' then it's just a matter of checking if two circles overlap, and that is basically the same as : centre points of two circles that are closer together then the two radii added.
|
|
|
|
|
Logged
|
|
|
|
|
Fallsburg
|
 |
« Reply #10 on: April 08, 2013, 12:34:13 PM » |
|
Also, if you are going to be doing this a lot, you would typically want to check to see if the distance squared is greater than the sum of the radii squared to save yourself a square root. i.e. change Point difference = new Point(circle1.x-circle2.x,circle1.y-circle.y); Boolean doesIntersect = Math.Sqrt(difference.x*difference.x+difference.y*difference.y) < (circle1.radius+circle2.radius);
to Point difference = new Point(circle1.x-circle2.x,circle1.y-circle.y); Number radiusSum = (circle1.radius+circle2.radius); Boolean doesIntersect = difference.x*difference.x+difference.y*difference.y < radiusSum*radiusSum;
|
|
|
|
|
Logged
|
|
|
|
|
|
|
TheHuckleberryWill
Guest
|
 |
« Reply #12 on: April 08, 2013, 11:36:42 PM » |
|
Ok, thanks I will give it a go! 
|
|
|
|
|
Logged
|
|
|
|
|