Skip to content

Instantly share code, notes, and snippets.

@ted80
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ted80/fa162297978ebd9bf8c9 to your computer and use it in GitHub Desktop.
Save ted80/fa162297978ebd9bf8c9 to your computer and use it in GitHub Desktop.
public function createExplosion(posX:Number, posY:Number, amount:int, color:uint, minspeed:Number, randspeed:Number, rot:Number = 0, sprayWidth:Number = 180, skip:Number = 0):void
{
var vel:Number = 0;
var r:Number = 0;
for (var i:int = 0; i < amount; i++)
{
r = rot - sprayWidth + (Math.random() * sprayWidth * 2);
particle.x = posX;
particle.y = posY;
particle.rotation = r / 180 * Math.PI;
particle.color = color;
vel = minspeed + Math.random() * randspeed;
setParticle(particle, Math.cos(r / 180 * Math.PI) * vel, Math.sin(r / 180 * Math.PI) * vel, time - skip);
}
}
public function setParticle(p:Particle, vx:Number, vy:Number, age:Number):void
{
p.copyVertexDataTransformedTo(mVertexData, nextPool * 4, p.transformationMatrix, vx, vy, age);
nextPool++;
if (nextPool > particlesLength - 1)
{
nextPool = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment