Skip to content

Commit

Permalink
Merge pull request #81 from pixijs/v3
Browse files Browse the repository at this point in the history
V3 to master
  • Loading branch information
andrewstart authored Feb 12, 2018
2 parents 8d90e50 + 0bfb294 commit bafd6ec
Show file tree
Hide file tree
Showing 36 changed files with 11,020 additions and 7,712 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ docs/docs
docs/examples/libs
node_modules
assets
npm-debug.log
npm-debug.log
ts-dist
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
language: node_js
node_js:
- "0.12"
before_install:
- npm install -g grunt-cli
- "8.9.4"
62 changes: 54 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

A particle system library for the [PixiJS](https://github.com/pixijs/pixi.js) library. Also, we created an [interactive particle editor](http://pixijs.github.io/pixi-particles-editor/) to design and preview custom particle emitters which utilitze PixiParticles.

## Breaking changes in v3 from v2
* On `Emitter`, `playOnce()` no longer sets `autoUpdate` to true. Set it manually before use.
`playOnceAndDestroy()` is unaffected.
* On `Emitter`, `start*` and `end*` properties for alpha, color, scale, and speed have been
replaced by a singly linked list of `PropertyNode` objects.
* Dropped support for PIXI v3. Please use v4.
* The library is no longer exported as a node export, only adding itself to the global PIXI namespace.

## Sample Usage

Please see the examples for various pre-made particle configurations.
Expand All @@ -24,20 +32,56 @@ var emitter = new PIXI.particles.Emitter(
// of the emitter
{
alpha: {
start: 0.8,
end: 0.1
list: [
{
value: 0.8,
time: 0
},
{
value: 0.1,
time: 1
}
],
isStepped: false
},
scale: {
start: 1,
end: 0.3
list: [
{
value: 1,
time: 0
},
{
value: 0.3,
time: 1
}
],
isStepped: false
},
color: {
start: "fb1010",
end: "f5b830"
list: [
{
value: "fb1010",
time: 0
},
{
value: "f5b830",
time: 1
}
],
isStepped: false
},
speed: {
start: 200,
end: 100
list: [
{
value: 200,
time: 0
},
{
value: 100,
time: 1
}
],
isStepped: false
},
startRotation: {
min: 0,
Expand All @@ -52,6 +96,8 @@ var emitter = new PIXI.particles.Emitter(
max: 0.5
},
frequency: 0.008,
spawnChance: 1,
particlesPerWave: 1,
emitterLifetime: 0.31,
maxParticles: 1000,
pos: {
Expand Down
62 changes: 39 additions & 23 deletions ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Typings for pixi-particles 2.1.9, requires Pixi.js typings
declare namespace PIXI.particles {
type TexSrc = string|PIXI.Texture;
type Color = {r:number, g:number, b:number};

export interface ValueList {
list: {value:number|string, time:number}[],
isStepped?: boolean;
ease?: (lerp:number)=>number|EaseSegment[];
}

export interface ParticleConstructor {
new (emitter:Emitter):Particle;
Expand Down Expand Up @@ -38,7 +45,6 @@ declare namespace PIXI.particles {
private _prevEmitterPos:PIXI.Point;
private _prevPosIsValid:boolean;
private _posChanged:boolean;
private _parentIsPC:boolean;
private _parent:PIXI.Container;
private _emit:boolean;
private _spawnTimer:number;
Expand All @@ -53,18 +59,14 @@ declare namespace PIXI.particles {
private _completeCallback:()=>void;

public particleImages:any[];
public startAlpha:number;
public endAlpha:number;
public startSpeed:number;
public endSpeed:number;
public startAlpha:PropertyNode;
public startSpeed:PropertyNode;
public minimumSpeedMultiplier:number;
public acceleration:PIXI.Point;
public maxSpeed:number;
public startScale:number;
public endScale:number;
public startScale:PropertyNode;
public minimumScaleMultiplier:number;
public startColor:[number, number, number];
public endColor:[number, number, number];
public startColor:PropertyNode;
public minLifetime:number;
public maxLifetime:number;
public minStartRotation:number;
Expand All @@ -89,6 +91,7 @@ declare namespace PIXI.particles {
public addAtBack:boolean;
public readonly particleCount:number;
public frequency:number;
public spawnChance:number;
public particleConstructor:ParticleConstructor;
public parent:PIXI.Container;
public emit:boolean;
Expand Down Expand Up @@ -116,12 +119,6 @@ declare namespace PIXI.particles {
}

export class Particle extends PIXI.Sprite {
private _sR:number;
private _sG:number;
private _sB:number;
private _eR:number;
private _eG:number;
private _eB:number;
private _doAlpha:boolean;
private _doScale:boolean;
private _doSpeed:boolean;
Expand All @@ -138,16 +135,12 @@ declare namespace PIXI.particles {
public age:number;
public ease:(time:number)=>number;
public extraData:any;
public startAlpha:number;
public endAlpha:number;
public startSpeed:number;
public endSpeed:number;
public alphaList:PropertyList;
public speedList:PropertyList;
public acceleration:PIXI.Point;
public maxSpeed:number;
public startScale:number;
public endScale:number;
public startColor:number[];
public endColor:number[];
public scaleList:PropertyList;
public colorList:PropertyList;

/** Note that for Particle, the parameter is an array of strings or PIXI.Textures, and an array of Textures is returned. */
public static parseArt(art:any):any;
Expand Down Expand Up @@ -182,6 +175,7 @@ declare namespace PIXI.particles {
public static hexToRGB(color:string, output?:[number, number, number]):[number, number, number];
public static generateEase(segments:EaseSegment[]):(time:number)=>number;
public static getBlendMode(name:string):number;
public static createSteppedGradient(list:{value:string, time:number}, numSteps?:number):PropertyNode;
}

export class PathParticle extends Particle {
Expand All @@ -193,4 +187,26 @@ declare namespace PIXI.particles {
public static parseArt(art:TexSrc[]):PIXI.Texture[];
public static parseData(data:{path:string}):any;
}

export class PropertyList {
public current: PropertyNode;
protected next: PropertyNode;
private isColor: boolean;
private ease: Function;

constructor(isColor?:boolean);
public interpolate(lerp:number):number;
public reset(first:PropertyNode):void;
}

export class PropertyNode {
public value: number|Color;
public time: number;
public next: PropertyNode;
public isStepped: boolean;
private interpolate: (lerp:number)=>number;
private ease: (lerp:number)=>number;

public static createList(data:ValueList):PropertyNode;
}
}
Loading

0 comments on commit bafd6ec

Please sign in to comment.