zame-particles 1.0.2

Particle system for OpenFl.

Released 2016-11-23.

To install, run:

haxelib install zame-particles 1.0.2

See using Haxelib in Haxelib documentation for more information.

Maintainerrestorer
Websitehttps://github.com/restorer/zame-haxe-particles/
Current version1.0.2
StatisticsInstalled 228 times
LicenseBSD
Tags cross, emitter, game, openfl, particle, particles

README.md

Particle system for OpenFl

(and for KHA, see below)

Demo

Features:

  • Can load files from Particle Designer or Particle Designer 2.
  • Support for embedded textures, both zipped or not.
  • Can load files from Starling Particle Editor.
  • Has 5 renderers - Sprites, DrawTiles (OpenFL 3) / Tilemap (OpenFL 4), Stage3d (OpenFL 4), and GL renderer.

Work in progress, more features coming.

OpenFL 3 note

This is last version that support OpenFL 3. It will be under branch openfl3.

Installation

Stable version from haxelib:

haxelib install zame-particles

Latest development version:

haxelib git zame-particles https://github.com/restorer/zame-haxe-particles.git

Usage

First of all, append following to your project.xml:

<haxelib name="zame-particles" />

Next, in code, create particle renderer and add it as child to container:

var renderer = DefaultParticleRenderer.createInstance();
addChild(cast renderer);

Than load particle emitter config from file, and add loaded particle system to renderer:

var ps = ParticleLoader.load("particle/fire.plist");
renderer.addParticleSystem(ps);

Finally, call emit() where you need:

ps.emit(stage.stageWidth / 2, stage.stageHeight / 2);

See minimal example under samples/minimal for more info.

If you have multiple particle systems (particle emitters), you should use only one renderer for them:

var renderer = DefaultParticleRenderer.createInstance();
addChild(cast renderer);

var ps1 = ParticleLoader.load("particle/ps1.plist");
renderer.addParticleSystem(ps1);

var ps2 = ParticleLoader.load("particle/ps2.plist");
renderer.addParticleSystem(ps2);

var ps3 = ParticleLoader.load("particle/ps3.plist");
renderer.addParticleSystem(ps3);

In some cases you may need several renderers, for example some particles on background layer, than player sprite, than some particles over player sprite. It is safe to use several renderers, but there is one important note about GL renderer for html5 with -Ddom. Browser give you limited number of WebGL contexts, so don't use too much renderers and test you game in various browsers.

Export notes

Embedded textures is supported, hovewer it is not recommended to use them for large images. For large texture images it is recommended to uncheck "embed" before export.

Renderer notes

  • html5 with -Ddom (GL renderer) - link
  • html5 in canvas mode (drawTiles renderer) - link
  • flash (old version of sprites renderer) - link
  • flash (stage3d renderer) - link

GL renderer is the best choise for html5 (with -Ddom) - it support many features and super fast. It use "hacked" version of OpenGLView to be able to add canvas with proper z-index. However GL renderer is available only for html with -Ddom.

Sprites renderer is best for flash, because it support color effects. If you use TilesheetStage3D library you may consider of using stage3d renderer, because it has much better performance.

Also use sprites renderer for cpp target (mac, linux, windows, android, ios) with OpenFL 4.

All other targets should use DrawTiles renderer for OpenFL 3 and Tilemap renderer for OpenFL 4:

  • html5 in canvas mode - still pretty fast, doesn't support color effects. OpenFL 3: Can render incorrectly due to bug in openfl, please apply this patch (or this for earlier versions of openfl) if you encounter it.
  • native - fast, on OpenFL 3 support color effects.

DefaultParticleRenderer

Usually you don't need to choose renderer manually, just use DefaultParticleRenderer.createInstance() to create best renderer.

OpenFL 4

Target / RendererDrawTilesGLViewSpritesStage3DTilemap
html5
-Ddom
n/aeffects: full,
speed: fast,

best choise
effects: no,
speed: very slow
n/aeffects: no,
speed: slow
html5
-Dcanvas
n/an/aeffects: no,
speed: almost fast
n/aeffects: no,
speed: fast,

best choise
html5
-Dwebgl
n/an/aeffects: almost full,
speed: almost fast,

best choise
n/aeffects: no,
speed: fast
cppn/an/aeffects: almost full,
speed: almost fast,

best choise
n/aeffects: no,
speed: fast
nekon/an/aeffects: almost full,
speed: very slow
n/aeffects: no,
speed: almost fast,

best choise
flashn/an/aeffects: partial,
speed: not so slow,

best choise
n/aeffects: no,
speed: not so slow

OpenFL 3

Target / RendererDrawTilesGLViewSpritesStage3DTilemap
html5
-Ddom
effects: no,
speed: slow
effects: full,
speed: fast,

best choise
effects: no,
speed: very slow
n/an/a
html5
-Dcanvas
effects: no,
speed: fast,

best choise
n/aeffects: no,
speed: slow
n/an/a
cpp
-Dlegacy
effects: partial,
speed: fast,

best choise
n/aeffects: no,
speed: almost fast
n/an/a
neko
-Dlegacy
effects: partial,
speed: fast,

best choise
n/aeffects: no,
speed: almost fast
n/an/a
flasheffects: no,
speed: slow
n/aeffects: partial,
speed: not so slow,

best choise
n/an/a
flash with
TilesheetStage3D
effects: no,
speed: slow
n/aeffects: partial,
speed: not so slow
effects: full,
speed: fast,

best choise
n/a

Product support

Product still is in development (but not active).

FeatureSupport status
New featuresYes
Non-critical bugfixesYes
Critical bugfixesYes
Pull requestsAccepted (after review)
IssuesMonitored
OpenFL version planned to supportUp to 4.x, and probably later, if Tilemap wouldn't be deprecated like Tilesheet
Estimated end-of-lifeUp to 2019

Roadmap for future

  • [x] Support for .json output format
  • [x] Support for .lap and .pex output formats
  • [x] Support for embedded textures
  • [x] Create importer for particles in luxeengine
  • [x] Implement SpritesRenderer
  • [x] Implement Stage3DRenderer
  • [x] Implement TilemapRenderer
  • [x] Fix rotation calculations (to be the same for all renderers)
  • [x] Partial support for pixi particles
  • [ ] Full support for pixi particles
  • [ ] Support for lime / snow directly without openfl / luxeengine
  • [ ] Support for HaxeFlixel and / or HaxePunk?
  • [ ] Support KHA directly in this library

KHA port by RafaelOliveira

https://github.com/RafaelOliveira/z-particles