HaxeFlixel/flixel — pull request #1323 by danim1130 (2014-10-05 14:56:06+00:00)
Title: Added polygon and circle hitboxes, raycasting.

As discussed in #1307, I have added a much more capable overlap checking system. Currently, I haven't changed anything in the base code, so there shouldn't be any compatibility issue (maybe if someone has extended FlxSprite, and defined a hitbox variable for it, but that's it). There are still a few things I want to add (like handling concave polygons better), but don't know when I can get around it. Also, there are a few things that aren't in use as of now. They will be used when I refractor the collision system, when I remove the old overlap system and integrate this one. For this, I would like it if there would be a separate branch for this on Github (altough I'm not exactly sure how this works, who creates it etc.).

The features:
-Added circle and convex polygon hitboxes (present in hxCollision).
-Added FlxHitboxList, which can be used to bundle multiple hitboxes into a bigger hitbox (not present in hxCollision)
-Raycasting (present in hxCollision, but it was buggy, so I had to do some tinkering)
-Added an overlap function so that using this overlap is almost the same as using FlxG.overlap.

How to use:
-Add a hitbox to a sprite (every parameter for the hitbox is in the sprites local coordinate system).
-Call flixel.hitbox.FlxOverlap.overlap() with the sprite.
-Use flixel.hitbox.FlxOverlap.castRay() to cast a ray against a sprite or an FlxGroup.

Here is a demo of it: http://www.fastswf.com/z77dAng
And the source code : http://pastebin.com/bRYY8VP3