Particles drawn in World/View space?

32 views
Skip to first unread message

iko...@gmail.com

unread,
Jan 13, 2016, 4:57:07 PM1/13/16
to Flambe
I have a spaceship that uses asteroid like controls and I want to use a particle emitter for the engines. Ideally what I would like to do is:

public function new() {
_emitter = mold.createEmitter();
_emitter.space = EmitterSpace.View; // This is the feature I am hoping for
owner.add(_emitter);
_emitter.anchorX._ = 5;
_emitter.anchorY._ = 5;
}

override public function onUpdate(dt:Float):Void {
_emitter.enable = _input.thrust.isDown;
}

But, instead I am having to figure out some hacky math to get this working as. If this is already possible, PLEASE let me know how. Also, if there is a working example, please direct me to it... I'm struggling to follow the transformations in the flambe source as I am new to the engine.

As far as creating a pull request for this now, I think all that really needs to be done is is create the EmitterSpace enum and create a switch/if in the draw function of EmitterSprite that draws the sprites correctly. Am I on the right track or am I way off?

iko...@gmail.com

unread,
Jan 13, 2016, 5:15:20 PM1/13/16
to Flambe, iko...@gmail.com
So I forgot an important detail, and here is the code I am using currently to :

override public function onUpdate(dt:Float):Void {

_emitter.enabled = _button.isDown;
if(_emitter.enabled) {
var vm = _anchor.getViewMatrix();
vm.transform(0, 0, _emitPoint);
_emitter.emitX._ = _emitPoint.x / _ctx.scaler.scale;
_emitter.emitY._ = _emitPoint.y / _ctx.scaler.scale;
_emitter.angle._ = -_player.rotation._ - 90;
}
}

_anchor is a Sprite that is a child of the player ship.
_ctx.scaler is a game scaling class that controls a sprite just like in Marks wiki: https://github.com/markknol/flambe-guide/wiki/Responsive-game

The tricky bit here is, everything works just peachy when the scale is 1:1. But once the game is scaled, that is where the issues come in.

Reply all
Reply to author
Forward
0 new messages