Created
May 16, 2016 20:43
-
-
Save starry-abyss/25f334cb94668005545e7c306e132491 to your computer and use it in GitHub Desktop.
Based on old forked version of HaxeFlixel (can be rewritten for official one), for future use :-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override function drawDebugBoundingBox(gfx: Graphics, rect:FlxRect, allowCollisions:Int) | |
{ | |
var drawX = rect.x;// + offset; | |
var drawY = rect.y;// + offset; | |
var offset = 2; | |
var offset2 = 2; | |
/*var offset2x = 0; | |
var offset2y = 0;*/ | |
var rectWidth = rect.width; | |
var rectHeight = rect.height; | |
var debugColor:FlxColor; | |
if (allowCollisions <= FlxObject.NONE) | |
{ | |
debugColor = FlxColor.BLUE; | |
return; | |
} | |
else if (allowCollisions != FlxObject.ANY) | |
{ | |
debugColor = FlxColor.PINK; | |
//debugColor = FlxColor.GREEN; | |
gfx.lineStyle(1, debugColor, 0.7); | |
gfx.drawRect(drawX, drawY, rectWidth, rectHeight); | |
rectWidth -= offset * 2; | |
rectHeight -= offset * 2; | |
debugColor = FlxColor.GREEN; | |
gfx.lineStyle(1, debugColor, 0.7); | |
/*var offset = 2; | |
var drawX = drawX + offset; | |
var drawY = drawY + offset; | |
var rectWidth = rectWidth - offset * 2; | |
var rectHeight = rectHeight - offset * 2; | |
*/ | |
if ((allowCollisions & FlxObject.LEFT) != 0) | |
{ | |
/*drawX -= offset; | |
drawY += offset;*/ | |
gfx.moveTo(drawX - offset2, drawY + offset2); | |
gfx.lineTo(drawX - offset2, drawY + offset2 + rectHeight); | |
} | |
if ((allowCollisions & FlxObject.RIGHT) != 0) | |
{ | |
/*drawX += offset * 2; | |
drawY += offset;*/ | |
gfx.moveTo(drawX + offset2 * 3 + rectWidth, drawY + offset2); | |
gfx.lineTo(drawX + offset2 * 3 + rectWidth, drawY + offset2 + rectHeight); | |
} | |
if ((allowCollisions & FlxObject.UP) != 0) | |
{ | |
/*drawX += offset; | |
drawY -= offset;*/ | |
gfx.moveTo(drawX + offset2, drawY - offset2); | |
gfx.lineTo(drawX + offset2 + rectWidth, drawY - offset2); | |
} | |
if ((allowCollisions & FlxObject.DOWN) != 0) | |
{ | |
/*drawX += offset; | |
drawY += offset * 2;*/ | |
gfx.moveTo(drawX + offset2, drawY + offset2 * 3 + rectHeight); | |
gfx.lineTo(drawX + offset2 + rectHeight, drawY + offset2 * 3 + rectHeight); | |
} | |
} | |
else | |
{ | |
debugColor = FlxColor.GREEN; | |
gfx.lineStyle(1, debugColor, 0.5); | |
gfx.drawRect(rect.x, rect.y, rect.width, rect.height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment