Particle Effects Generation

Particle effects can add a lot of detail and pop to your graphics and gameplay. Here is an implementation I use to incorporate single pixel particle effects for sparks and explosion details.
FireGib = EntityParticle.extend({ // shorter lifetime lifetime: 1.0, fadetime: 0.5, // velocity value to be set vel: null, gravityFactor: 0, // bounce a little less bounciness: 0.6, // add animation sheet of sprites animSheet: new ig.AnimationSheet('media/sprites/burnpix.png',1,1), init:function( x, y, settings ){ // add ember animation this.addAnim( 'idle', 0.3, [0,1,2,3] ); // update random velocity to create starburst effect this.vel = { x: (Math.random() < 0.5 ? -1 : 1)*Math.random()*100, y: (Math.random() < 0.5 ? -1 : 1)*Math.random()*100 }; // send to parent this.parent( x, y, settings ); } });
I have a complete walkthrough at clokwork.net and the source code for a game using these effects, PiSpace, and the particle.js entities are on GitHub.
Please email me with any questions if you like.
This is just a sample. Hit the links for the complete code.
Contributed by:
clok
View Profile
clok
Category:Game Elements
Updated:March 15, 2012
Rating:
Your Rating (0)
Average Rating (5)
