I use haxelib version (1.0.2). I just copy code from github samples/minimal and as I said: flash target works well, html5 convert everything in black screen.
OK, I found the problem- because I encapsulate particle engine in it’s own class MyParticle.hx I add renderer as a child of class before instance of class is added to display list.
var classInstance = new MyParticles()
classInstance.init();
MyParticles class:
public function init():Void
{
var renderer = DefaultParticleRenderer.createInstance();
addChild(cast renderer);
ps = ParticleLoader.load("particle/particle.plist");
renderer.addParticleSystem(ps);
particleDuration = 1.0;
ps.duration = particleDuration;
}
and this line solve the problem:
var classInstance = new MyParticles();
addChild(classInstance );
classInstance.init();
Adding encapsulated instance after adding particle system also works fine for me:
class App extends Sprite {
public function new() : Void {
super();
ready();
}
private function ready() : Void {
var classInstance = new MyParticles();
classInstance.init();
addChild(classInstance);
}
}
class MyParticles extends Sprite {
public function new() : Void {
super();
}
public function init() : Void {
var renderer = DefaultParticleRenderer.createInstance();
addChild(cast renderer);
var ps = ParticleLoader.load("particle/fire.plist");
renderer.addParticleSystem(ps);
// stage is not available if sprite is not added to display list,
// so use openfl.Lib.current.stage in that case
var currentStage = (stage != null ? stage : openfl.Lib.current.stage);
ps.emit(currentStage.stageWidth / 2, currentStage.stageHeight / 2);
}
}
Maybe you use stage before adding MyParticles to display list?