drag to select fix deselection when clicking background

This commit is contained in:
2022-08-17 23:38:14 +00:00
parent 0464f3c486
commit 310aa7371e

View File

@@ -56,15 +56,18 @@ class DragToSelectPlugin extends FlxBasic {
dragStates[FlxG.state].selectedSprites = [];
}
var wasJustPressed = false;
public override function update(elapsed:Float) {
if (dragStates.exists(FlxG.state)) {
var dragState = dragStates[FlxG.state];
dragState.debugLayer.clear();
// Might have to skip a frame after justPressed, so KissExtendedSprites
// have to skip a frame after justPressed, so KissExtendedSprites
// can get first access to the mouse input
if (FlxMouseControl.dragTarget == null) {
if (FlxG.mouse.justPressed) {
if (wasJustPressed && FlxMouseControl.clickTarget == null) {
deselectSprites();
dragState.firstCorner = FlxG.mouse.getWorldPosition(dragState.camera);
}
dragState.secondCorner = FlxG.mouse.getWorldPosition(dragState.camera);
@@ -111,6 +114,7 @@ class DragToSelectPlugin extends FlxBasic {
}
}
}
wasJustPressed = FlxG.mouse.justPressed;
}
}
}