Better mouse overlapping function for CoolUtil (#813)
* mouseOverlaps * This makes more sense yeah thinking of not even allowing disjointed overlap checks keeping it for now * oops forgot to define that var as flxcamera
This commit is contained in:
@@ -880,7 +880,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]);
|
||||
@@ -1027,6 +1027,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
|
||||
@@ -1077,7 +1091,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;
|
||||
@@ -1224,8 +1238,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";
|
||||
|
||||
Reference in New Issue
Block a user