zame-particles 1.0.3

Particle system for OpenFl.

Released 2017-04-18.

To install, run:

haxelib install zame-particles 1.0.3

See using Haxelib in Haxelib documentation for more information.

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

README.md

Particle system for OpenFl

(and for KHA, see below)

Demo (old version)

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 3 renderers - Sprites, Tilemap (OpenFL 4), and GL renderer.

Work in progress, more features coming.

OpenFL 3 note

This version supports OpenFL 4 only. If you still use OpenFL 3, find older version 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

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. Also use sprites renderer for cpp target (mac, linux, windows, android, ios) with OpenFL 4.

All other targets should use Tilemap renderer.

  • html5 in canvas mode - fast, but doesn't support color effects.
  • native - fast and doesn't support color effects too (but this can be changed in future).

DefaultParticleRenderer

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

Renderers comparison

Target / RendererGLViewSpritesTilemap
html5
-Ddom
effects: full,
speed: fast,

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

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

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

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

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

best choise
effects: no,
speed: not so slow

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
  • [ ] Allow to pass BitmapData to loader
  • [ ] Allow to change particle system parameters dynamically
  • [ ] Move non openfl-related stuff to core (particle, particle system, utils, base loaders)
  • [ ] 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