diff --git a/CHANGELOG.md b/CHANGELOG.md index e0c7babb84..b5912a4c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ - `FlxPath`: added `immovable` bool (previously object were always immovable when following paths) ([#2480](https://github.com/HaxeFlixel/flixel/pull/2480)) - `FlxPathDrawData`: added `myFlxPath.debugDrawData` to allow custom colors and draw properties ([#2480](https://github.com/HaxeFlixel/flixel/pull/2480)) - `FlxAxes`: added `x` and `y` getters and `NONE` value ([#2480](https://github.com/HaxeFlixel/flixel/pull/2480)) -- `FlxTween`: added `ShakeTween` and `FlxTween.shake()` helper ([#2549](https://github.com/HaxeFlixel/flixel/pull/2549)) +- `FlxTween`: added `ShakeTween` and `FlxTween.shake()` helper ([#2549](https://github.com/HaxeFlixel/flixel/pull/2549)) +- `WatchFrontEnd`: added `FlxG.watch.addFunction` ([#2500](https://github.com/HaxeFlixel/flixel/pull/2500)) #### Bugfixes: diff --git a/flixel/system/debug/watch/Watch.hx b/flixel/system/debug/watch/Watch.hx index 9a4bc3f06c..f6dc8ab132 100644 --- a/flixel/system/debug/watch/Watch.hx +++ b/flixel/system/debug/watch/Watch.hx @@ -62,6 +62,8 @@ class Watch extends Window displayName.isNullOrEmpty(); case EXPRESSION(expression, _): expression.isNullOrEmpty(); + case FUNCTION(func): + func == null; } } diff --git a/flixel/system/debug/watch/WatchEntry.hx b/flixel/system/debug/watch/WatchEntry.hx index ec6690f8d0..f8178d6257 100644 --- a/flixel/system/debug/watch/WatchEntry.hx +++ b/flixel/system/debug/watch/WatchEntry.hx @@ -58,6 +58,7 @@ class WatchEntry extends Sprite implements IFlxDestroyable case FIELD(_, _): 0xFFFFFF; case QUICK(_): 0xA5F1ED; case EXPRESSION(_, _): 0xC4FE83; + case FUNCTION(_): 0xF1A5A5; } } @@ -96,6 +97,7 @@ class WatchEntry extends Sprite implements IFlxDestroyable case EXPRESSION(expression, _): setNameText(expression); case QUICK(_): + case FUNCTION(_): } } @@ -120,6 +122,8 @@ class WatchEntry extends Sprite implements IFlxDestroyable #end case QUICK(value): value; + case FUNCTION(func): + func(); } } diff --git a/flixel/system/debug/watch/WatchEntryData.hx b/flixel/system/debug/watch/WatchEntryData.hx index 90fc1d02fb..4a243433d5 100644 --- a/flixel/system/debug/watch/WatchEntryData.hx +++ b/flixel/system/debug/watch/WatchEntryData.hx @@ -20,4 +20,9 @@ enum WatchEntryData * Haxe expression evaluated with hscript. */ EXPRESSION(expression:String, parsedExpr:#if hscript Expr #else String #end); + + /** + * A function that returns the value to display. + */ + FUNCTION(func:()->Dynamic); } diff --git a/flixel/system/frontEnds/WatchFrontEnd.hx b/flixel/system/frontEnds/WatchFrontEnd.hx index c9ecdab046..d190a27e1d 100644 --- a/flixel/system/frontEnds/WatchFrontEnd.hx +++ b/flixel/system/frontEnds/WatchFrontEnd.hx @@ -98,6 +98,20 @@ class WatchFrontEnd FlxG.game.debugger.watch.remove(displayName, null); #end } + + public function addFunction(displayName:String, func:()->Dynamic):Void + { + #if FLX_DEBUG + FlxG.game.debugger.watch.add(displayName, FUNCTION(func)); + #end + } + + public function removeFunction(displayName:String):Void + { + #if FLX_DEBUG + FlxG.game.debugger.watch.remove(displayName, null); + #end + } /** * Add the mouse coords to the watch window. Useful for quickly