Skip to content

Instantly share code, notes, and snippets.

@markknol
Last active December 25, 2015 06:29
Show Gist options
  • Save markknol/6932447 to your computer and use it in GitHub Desktop.
Save markknol/6932447 to your computer and use it in GitHub Desktop.
Nape Debug View in Haxe Flambe
//You can use it like this:
System.root.add(new NapeDebugView());
package nl.stroep.games.components;
import flambe.Component;
import nape.space.Space;
/**
* @author Mark Knol [blog.stroep.nl]
*/
class NapeDebugView extends Component
{
private var _space:Space;
#if flash
private var _debugView:nape.util.ShapeDebug;
#end
public function new(space:Space, width:Int, height:Int)
{
_space = space;
#if flash
_debugView = new nape.util.ShapeDebug(width, height);
flash.Lib.current.stage.addChild(_debugView.display);
#end
}
override public function onUpdate(dt:Float)
{
super.onUpdate(dt);
#if flash
//var sprite = owner.get(Sprite);
//_debugView.display.x = sprite.x._;
//_debugView.display.y = sprite.y._;
_debugView.clear();
_debugView.draw(_space);
#end
}
override public function dispose()
{
#if flash
flash.Lib.current.stage.removeChild(_debugView.display);
_debugView = null;
#end
super.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment