DebugLayer use zoom-independent thickness of 1

This commit is contained in:
2022-08-14 21:49:02 +00:00
parent 7aa6e575f2
commit dfebe243cc
2 changed files with 7 additions and 15 deletions

View File

@@ -35,14 +35,9 @@
(method &override :Void update [:Float elapsed]
(super.update elapsed)
(debugLayer.clear)
(debugLayer.drawRect 0 0 100 100 FlxColor.TRANSPARENT (object thickness t color FlxColor.LIME))
(when FlxG.keys.justPressed.ONE
(+= t 1))
(when FlxG.keys.justPressed.TWO
(-= t 1))
(#when debug
(debugLayer.clear)
(doFor s rewardSprites
//(s.drawCircle s.origin.x s.origin.y 5 FlxColor.LIME)
//(debugLayer.drawCircle (- s.x cameraBounds.x) (- s.y cameraBounds.y) 5 FlxColor.LIME)
@@ -50,7 +45,7 @@
(let [matchZones [(matchZoneLeft s) (matchZoneRight s)(matchZoneUp s)(matchZoneDown s)]]
(doFor z matchZones
(unless z.isEmpty
(debugLayer.drawFlxRect z FlxColor.TRANSPARENT (object thickness 1 color FlxColor.RED)))))))
(debugLayer.drawFlxRect z FlxColor.RED))))))
(pieceCamera.updateScrollWheelZoom elapsed 5)
(pieceCamera.updateMouseBorderControl elapsed KEYBOARD_SCROLL_SPEED 0.002 uiCamera)

View File

@@ -12,23 +12,20 @@ using kiss_flixel.DebugLayer;
@:build(kiss.Kiss.build())
class DebugLayer extends FlxTypedGroup<FlxSprite> {
public function drawRect(X:Float, Y:Float, Width:Float, Height:Float, FillColor:FlxColor = FlxColor.WHITE, ?lineStyle:Null<LineStyle>, ?drawStyle:Null<DrawStyle>):FlxSprite {
var thickness = 1.0;
if (lineStyle != null) {
thickness = lineStyle.thickness;
}
public function drawRect(X:Float, Y:Float, Width:Float, Height:Float, outlineColor:FlxColor = FlxColor.WHITE):FlxSprite {
var thickness = 1.0 / cameras[0].zoom;
var s = new FlxSprite(X-thickness/2, Y-thickness/2);
// TODO test where thickness appears - is it center-out from the given border?
s.mg(Width + thickness, Height + thickness);
s.drawRect(thickness/2, thickness/2, Width, Height, FillColor, lineStyle, drawStyle);
s.drawRect(thickness/2, thickness/2, Width, Height, FlxColor.TRANSPARENT, {color: outlineColor, thickness: thickness});
add(s);
return s;
}
public function drawFlxRect(rect:FlxRect, FillColor:FlxColor = FlxColor.WHITE, ?lineStyle:Null<LineStyle>, ?drawStyle:Null<DrawStyle>):FlxSprite {
return drawRect(rect.x, rect.y, rect.width, rect.height, FillColor, lineStyle, drawStyle);
public function drawFlxRect(rect:FlxRect, outlineColor:FlxColor = FlxColor.WHITE):FlxSprite {
return drawRect(rect.x, rect.y, rect.width, rect.height, outlineColor);
}
public static function mg(s:FlxSprite, Width:Float, Height:Float):FlxSprite {