Created
May 21, 2016 20:23
-
-
Save starry-abyss/769c5d3ba27867cbe303d0eb80973415 to your computer and use it in GitHub Desktop.
A cut from my project for making debug tracker windows more interactive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// objectTrackerWindows is declared as Map<BaseObject, Window> | |
// BaseObject is my base class for objects, you can replace it with FlxSprite | |
for (object in objectTrackerWindows.keys()) | |
{ | |
var window = objectTrackerWindows.get(object); | |
if (!object.alive) | |
{ | |
window.close(); | |
objectTrackerWindows.remove(object); | |
} | |
else | |
{ | |
var point = FlxPoint.get(); | |
object.getScreenPosition(point, FlxG.camera); | |
window.x = (point.x + object.width / 2) * scaleMode.zoom - window.width / 2; | |
window.y = point.y * scaleMode.zoom - window.height - 10; | |
point.put(); | |
} | |
} | |
if (FlxG.mouse.justPressedRight) | |
for (spriteBasic in environment.objectGroup) | |
{ | |
if (Std.is(spriteBasic, BaseObject)) | |
{ | |
var object = cast(spriteBasic, BaseObject); | |
if (object.alive && object.overlapsPoint(FlxG.mouse.getWorldPosition())) | |
{ | |
if (objectTrackerWindows.exists(object)) | |
{ | |
objectTrackerWindows.get(object).close(); | |
objectTrackerWindows.remove(object); | |
} | |
else | |
{ | |
var window = FlxG.debugger.track(object); | |
objectTrackerWindows.set(object, window); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment