Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075922 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:46:00 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)FlashPunk rotate hitbox's
Pages: [1]
Print
Author Topic: FlashPunk rotate hitbox's  (Read 1200 times)
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
Level 10
*****


Retromite code daemon


View Profile WWW Email
« 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
Level 10
*****


Fear the CircleCat


View Profile
« 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... Tongue

Thanks for trying though!
Logged
Noogai03
Level 6
*


WHOOPWHOOPWHOOPWHOOP


View Profile WWW Email
« 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
Level 6
*


WHOOPWHOOPWHOOPWHOOP


View Profile WWW Email
« 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 Tongue
Logged
nikki
Level 10
*****


View Profile Email
« Reply #9 on: April 08, 2013, 07:39:28 AM »

Quote
...just use bounding circles instead...
Quote
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
Level 10
*****


Fear the CircleCat


View Profile
« 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
Code:
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

Code:
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
Serapth
Level 2
**


View Profile
« Reply #11 on: April 08, 2013, 02:02:18 PM »

I've done a few tutorials on this subject, that should prove useful.  Examples are JS/Easel, but should be easily followed by an AS programmer.

Axis aligned bounding boxes Part 1

Axis aligned bounding boxes part 2 ('Rotating' covered)

And...

Bounding circles
Logged
TheHuckleberryWill
Guest
« Reply #12 on: April 08, 2013, 11:36:42 PM »

I've done a few tutorials on this subject, that should prove useful.  Examples are JS/Easel, but should be easily followed by an AS programmer.

Axis aligned bounding boxes Part 1

Axis aligned bounding boxes part 2 ('Rotating' covered)

And...

Bounding circles

Ok, thanks I will give it a go! Tongue
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic