Hey all, here’s a quick tip on how to fix an issue with your hitboxes in Flixel. Let me know if you’ve heard this one before.

The Problem

Have you ever heard of an issue where you’re working on your game and after your character moves outside the initial screen size, your character doesn’t collide with anything anymore? This is an issue I encountered recently, and with help from the Flixel community, it was a simple fix, which I will share with you.

The World Bound Fix

The fix is one line of code. This line will update the positions so that Flixel registers your overlaps and collisions once again. See below:

* From The Flixel Documentation
* The dimensions of the game world, used by the quad tree for collisions and overlap checks.
* Use .set() instead of creating a new object!
* ——
* By updating the value of this element, we can fix our collision detection once again.
* Best to call this in your update function.
view raw CollisionFix.hx hosted with ❤ by GitHub

See? Easy right? That’s the fix. By updating the world bounds, we allow the quadtree, which is being used for collision detection to properly register the collisions you wish to make once again. I hope it helps you with your game.

With that said, have a good one and take care!! Good luck game making!!

%d bloggers like this: