diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 6f570949b..dc441a518 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,20 @@ final class CoolUtil return result; } + /** + * 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 camera you want to check overlap on. Uses the sprite's camera by default. + * @return Bool + */ + public static function mouseOverlaps(sprite:FlxBasic, ?camera:FlxCamera) { + 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); + } + /** * Sorts an array alphabetically. * @param array Array to sort @@ -1053,7 +1067,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 +1214,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 +1281,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); }