From 25c41cd5fef8523df6d89c0a885b0f4e6f92344c Mon Sep 17 00:00:00 2001 From: Bitto Date: Thu, 6 Nov 2025 16:06:26 +0000 Subject: [PATCH 1/3] mouseOverlaps --- source/funkin/backend/utils/CoolUtil.hx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 6f570949b..d1753fa3f 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -856,7 +856,7 @@ final class CoolUtil */ public static inline function browsePath(path:String) { var formattedPath:String = Path.normalize(path); - + #if windows formattedPath = formattedPath.replace("/", "\\"); Sys.command("explorer", [formattedPath]); @@ -1003,6 +1003,21 @@ final class CoolUtil return result; } + /** + * Returns if the mouse is overlapping the sprite on the given camera, taking the camera's position and scroll into account. + * + * @param sprite Any `FlxBasic` + * @param camera The desired "screen" to check overlap on. If `null`, the first camera in `FlxG.state.cameras` is used (normally `FlxG.camera`). + * @return Bool + */ + public static function mouseOverlaps(sprite:FlxBasic, ?camera:FlxCamera) { + if (camera == null) + camera = FlxG.state.cameras[0]; + + var posthing = FlxG.mouse.getWorldPosition(camera); + return posthing != null && FlxMath.inBounds(posthing.x, sprite.x, sprite.x + sprite.width) && FlxMath.inBounds(posthing.y, sprite.y, sprite.y + sprite.height); + } + /** * Sorts an array alphabetically. * @param array Array to sort @@ -1053,7 +1068,7 @@ final class CoolUtil r.add(str); return r.toString(); } - + public static inline function bound(Value:Float, Min:Float, Max:Float):Float { #if cpp var _hx_tmp1:Float = Value; @@ -1200,8 +1215,8 @@ final class CoolUtil /** * ! REQUIRES FULL PATH!!! - * @param path - * @return Bool + * @param path + * @return Bool */ public static function imageHasFrameData(path:String):String { if (FileSystem.exists(Path.withExtension(path, "xml"))) return "xml"; @@ -1267,7 +1282,7 @@ final class CoolUtil public static function getAnimsListFromSprite(spr:FunkinSprite):Array { if (spr.animateAtlas != null) { return [for (symbol => timeline in spr.animateAtlas.anim.symbolDictionary) symbol]; - } else + } else return getAnimsListFromFrames(spr.frames); } From 826297308e227e916636532a1c078edd5ba4ffd8 Mon Sep 17 00:00:00 2001 From: Bitto Date: Sun, 30 Nov 2025 14:20:49 +0000 Subject: [PATCH 2/3] This makes more sense yeah thinking of not even allowing disjointed overlap checks keeping it for now --- source/funkin/backend/utils/CoolUtil.hx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index d1753fa3f..b3b0ce942 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -1004,17 +1004,16 @@ final class CoolUtil } /** - * Returns if the mouse is overlapping the sprite on the given camera, taking the camera's position and scroll into account. + * Returns if the mouse is overlapping the sprite on a given camera, taking the camera's position, scroll and zoom into account. * * @param sprite Any `FlxBasic` - * @param camera The desired "screen" to check overlap on. If `null`, the first camera in `FlxG.state.cameras` is used (normally `FlxG.camera`). + * @param camera The camera you want to check overlap on. Uses the sprite's camera by default. * @return Bool */ public static function mouseOverlaps(sprite:FlxBasic, ?camera:FlxCamera) { - if (camera == null) - camera = FlxG.state.cameras[0]; + var camToCheck = camera ?? sprite.camera; + var posthing:FlxPoint = FlxG.mouse.getWorldPosition(camToCheck); - var posthing = FlxG.mouse.getWorldPosition(camera); return posthing != null && FlxMath.inBounds(posthing.x, sprite.x, sprite.x + sprite.width) && FlxMath.inBounds(posthing.y, sprite.y, sprite.y + sprite.height); } From 478aa2d3d696c02e96c0381b21549e90969f5572 Mon Sep 17 00:00:00 2001 From: Bitto Date: Sun, 30 Nov 2025 14:23:23 +0000 Subject: [PATCH 3/3] oops forgot to define that var as flxcamera --- source/funkin/backend/utils/CoolUtil.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index b3b0ce942..dc441a518 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -1011,7 +1011,7 @@ final class CoolUtil * @return Bool */ public static function mouseOverlaps(sprite:FlxBasic, ?camera:FlxCamera) { - var camToCheck = camera ?? sprite.camera; + var camToCheck:FlxCamera = camera ?? sprite.camera; var posthing:FlxPoint = FlxG.mouse.getWorldPosition(camToCheck); return posthing != null && FlxMath.inBounds(posthing.x, sprite.x, sprite.x + sprite.width) && FlxMath.inBounds(posthing.y, sprite.y, sprite.y + sprite.height);