shin10 / Starling-FFParticleSystem

Improved particle system for the Starling framework
42 stars 22 forks source link

Not working with Starling 2.0 #12

Closed IPv6 closed 8 years ago

IPv6 commented 8 years ago

Used this extesion a lot, great work!

But after upgrading to Starling 2.0 it stops compiling // starling.core.RenderSupport and starling.utils.VertexData not found anymore.

Are there any plans to update for 2.0 compatibility? Hoping there is not much to do.

Chris1898 commented 8 years ago

Just wanted to ask the same. Any plans for 2.0? Thanks in advance!

IPv6 commented 8 years ago

@Chris1898 in fact there is official pdparticlesystem, ported to 2.0 with same *.pex file support but there is a question about perfomance compared this super-optimized solution :)

Diamanter commented 8 years ago

Yes, we want it for Starling 2 too )

shin10 commented 8 years ago

Hi,

so I just committed an update. Documentation hasn't been updated and there are some files I added for testing. So I'm calling this more an alpha version, but have a try.

The system is using styles/effects now, like other Starling DisplayObjects for rendering. I added a style for mobile devices to use drawTrianglesInstanced. That's why you'll have to initialize the system a little differently than in previous versions.

FFParticleSystem.initPool(4096, false); FFParticleSystem.defaultStyle.effectType.createBuffers(4096, 16); And don't forget to dispose the buffers of the effect later on.

FFParticleSystem.styles is a list of styles that will get tested by the first call of FFParticleSystem.defaultStyle. You can either manipulate this list beforehand or manually set the defaultStyle. Of course you should be able to write custom styles/effects and use different styles on each system as well.

That's it for now. Cheers

ps: to use instanced drawing, you'll have to use the latest version of the AGALMiniAssembler, which currently isn't part of Starling. https://github.com/adobe-flash/graphicscorelib/blob/master/src/com/adobe/utils/v3/AGALMiniAssembler.as I added the file to the sources, but you'll have to update it within Starling yourself.

byem commented 8 years ago

Hi. Checked out new version and found strange bug, If ffparticlesystem with limited emissionTime was removed from stage and added again later - it will continue emitting even after emissionTime was passed. Sample code is something like: FFParticleSystem.defaultStyle = FFParticleStyle; FFParticleSystem.initPool(4096, false); FFParticleSystem.defaultStyle.effectType.createBuffers(4096, 16); var so:SystemOptions = SystemOptions.fromXML(new XML(FilesManager.getFile("assets/particles/4/particle.pex")), texture); var p:FFParticleSystem = new FFParticleSystem(so) p.emitterX = p.emitterY = 10; addChild(p); p.start(0.4); Starling.juggler.delayCall(function():void{p.removeFromParent(false)}, .2); Starling.juggler.delayCall(function():void{addChild(p)}, 2.2);

shin10 commented 8 years ago

Hi byem,

that's nothing that has changed. It's a feature that has been there quite some time. The addedToStageHandler will automatically call start(__emissionTime) to auto-restart with the remaining time. Anyway, if the duration is 0, it will use the default duration set within the .pex/SystemOptions.

I think the reason is obvious. Whoever adds a particle system to the displaylist wants to play it. If another duration is necessary he may override it by calling start(). What you intend to do could either be done by adding a condition like this ...

Starling.juggler.delayCall(function():void {
    if(p.emitting)
        addChild(p);
}, 2.2 );

... or listening for the COMPLETE event. Anyhow, note that there is a slight difference between p.complete and p.emitting and pick it according to your needs.