Skip to content

Commit

Permalink
Attached often used functions to instances for speed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Start committed Mar 17, 2015
1 parent f7af5a9 commit 60900a6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
17 changes: 16 additions & 1 deletion dist/pixi-particles.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@
* @private
*/
this._oneOverLife = 0;

//save often used functions on the instance instead of the prototype for better speed
this.init = this.init;
this.Particle_init = this.Particle_init;
this.update = this.update;
this.Particle_update = this.Particle_update;
this.applyArt = this.applyArt;
this.kill = this.kill;
};

// Reference to the prototype
Expand Down Expand Up @@ -1162,7 +1170,7 @@
this.rotation = 0;
/**
* The world position of the emitter's owner, to add spawnPos to when
* spawning particles. To change this, use updateSpawnOrigin().
* spawning particles. To change this, use updateOwnerPos().
* @property {PIXI.Point} ownerPos
* @default {x:0, y:0}
* @readOnly
Expand Down Expand Up @@ -1239,6 +1247,13 @@

if(particleImages && config)
this.init(particleImages, config);

//save often used functions on the instance instead of the prototype for better speed
this.recycle = this.recycle;
this.update = this.update;
this.rotate = this.rotate;
this.updateSpawnPos = this.updateSpawnPos;
this.updateOwnerPos = this.updateOwnerPos;
};

// Reference to the prototype
Expand Down
2 changes: 1 addition & 1 deletion dist/pixi-particles.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/Emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
this.rotation = 0;
/**
* The world position of the emitter's owner, to add spawnPos to when
* spawning particles. To change this, use updateSpawnOrigin().
* spawning particles. To change this, use updateOwnerPos().
* @property {PIXI.Point} ownerPos
* @default {x:0, y:0}
* @readOnly
Expand Down Expand Up @@ -308,6 +308,13 @@

if(particleImages && config)
this.init(particleImages, config);

//save often used functions on the instance instead of the prototype for better speed
this.recycle = this.recycle;
this.update = this.update;
this.rotate = this.rotate;
this.updateSpawnPos = this.updateSpawnPos;
this.updateOwnerPos = this.updateOwnerPos;
};

// Reference to the prototype
Expand Down
8 changes: 8 additions & 0 deletions src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@
* @private
*/
this._oneOverLife = 0;

//save often used functions on the instance instead of the prototype for better speed
this.init = this.init;
this.Particle_init = this.Particle_init;
this.update = this.update;
this.Particle_update = this.Particle_update;
this.applyArt = this.applyArt;
this.kill = this.kill;
};

// Reference to the prototype
Expand Down

0 comments on commit 60900a6

Please sign in to comment.