Hellooo,
I was wondering if theres an easy way to make lines that trail an entity’s position? Do I have to use an emitter for that or can I use Draw.line in the render method?
Thanks, Taylor
Hellooo,
I was wondering if theres an easy way to make lines that trail an entity’s position? Do I have to use an emitter for that or can I use Draw.line in the render method?
Thanks, Taylor
If you store a Vector of your Entity’s positions every update()
, you could use Draw.line
to render it.
You’d probably want to make sure to limit the size of the Vector, though, and you might need to do some optimization to reduce Draw
calls, but this should get you started.
Well, looks like I’m late, but this works as well (though it’s probably not as good a solution):
private var img:Image;
private var bmd:BitmapData;
private var oldMouseX:Number;
private var oldMouseY:Number;
override public function render():void {
Draw.setTarget(bmd);
Draw.line(oldMouseX,oldMouseY,Input.mouseX,Input.mouseY, 0xffffff);
Draw.resetTarget();
oldMouseX = Input.mouseX;
oldMouseY = Input.mouseY;
super.render();
}
this gets you a bmd with a line following your mouse – I guess it could be easily done for an entity
im not sure this is as flexible a solution as jonathan’s…by implementing his method I can control the length of the line, and also use stuff like squares and circles. Thanks though!