Draknek/FlashPunk — pull request #122 by azrafe7 (2013-11-12 22:43:21+00:00)
Title: Additional Draw methods to facilitate debugging

Added a bunch of method to the Draw class:
- dot()
- arrow()
- arrowPlus()
- arc()
- arcPlus() (also supports filling)
- rotatedRect()

They should be pretty self-explanatory (and are in the first two commits).

In the last commit instead I've added:
- enqueueCall()
- renderCallQueue()

They're a bit trickier to use, but I'm finding them very useful for debugging.
Basically, instead of having to override the render function in your World and create member vars to use in there for debugging purposes, you can just use Draw.enqueueCall(), and pass in a function you wish to be executed at the end of the next render step. Then the queue will be automatically emptied.

Maybe an example will clear things a bit. Suppose you want to draw an arrow from your player to the nearest enemy, and that you need to do this based on some logic coded in the update function of your World. You could simply write this (instead of saving all the necessary variables from within the if block and reuse them in render):

```as3
override public function update():void {
...
var nearest:Entity;
if (nearest = nearestToEntity("enemy", player)) {
var dist:Number = FP.distance(player.x, player.y, nearest.x, nearest.y);
if (dist <= RADAR_DISTANCE) {
...
Draw.enqueueCall(function():void {
Draw.arrow(player.x, player.y, nearest.x, nearest.y);
trace(dist);
});
}
}
...
}
```

test: [code](https://dl.dropboxusercontent.com/u/32864004/dev/FPDemo/DrawMethodsTest.zip) | [swf](https://dl.dropboxusercontent.com/u/32864004/dev/FPDemo/DrawMethodsTest.swf)