FP is bitmap based but you can use vector graphic and rasterize them
This can really usefull when you have to draw curves or handle multiple resolution and so on.
here a basic example.
package
{
import flash.display.BitmapData;
import flash.display.Shape;
import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.graphics.Image;
/**
* ...
* @author YopSolo
*/
public class MyEntity extends Entity
{
public function MyEntity()
{
// creating a vector shape using build-in method
var sh:Shape = new Shape();
var radius:int = 25;
sh.graphics.beginFill( 0xFF0099 );
sh.graphics.drawCircle(radius, radius, radius );
sh.graphics.endFill();
// rasterizing the vector graphics
var dat:BitmapData = new BitmapData(radius * 2 , radius * 2, true, 0x0);
dat.draw( sh );
graphic = new Image( dat );
graphic.x = FP.halfWidth - radius;
graphic.y = FP.halfHeight - radius;
}
override public function update():void
{
trace("MyEntity updates.");
}
}
}
The rendering performance are the same (cause it’s now a bitmap) but there is a cost when you use the draw() method.
So you have to create your assets before using them (during the preload of your game/level for example)