Sign in to follow this  

Horizontal Flip Custom HitBoxes With Sprite Flip in 2D Game

This topic is 836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello Everyone, 

 

I have Custom Hitboxes defined per sprite for enemies as std::vector<Rectangle> where each rectangle is relative coordinates to the sprite, when doing collision detection, i just translate those Rects coordinates to screen coordinates and check for colliding objects and it works fine when sprite is not flipped and its in the same shape when the hitboxes were defined for it, however, in some cases when the enemy gets behind the player character it flips horizontally to give the enemy the ability to attack the player as well, there is no vertical flipping, thus hitboxes positions are now invalid and will cause wrong collision detection, i'm trying to find an algorithm to flip hitboxes sort of mirroring them.

what is the easiest way to (not sure about the right term here) flip hitboxes to match same positions when the sprite gets flipped.

Thanks for help.

Share this post


Link to post
Share on other sites

This topic is 836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this