| 1 |
private function createParticles( count ):void{ |
| 2 |
var anchorPoint = 0; |
| 3 |
for(var i:uint = 0; i < count; i++){ |
| 4 |
|
| 5 |
var particle:Object; |
| 6 |
if( inactiveFireParticles.length > 0 ){ |
| 7 |
particle = inactiveFireParticles.shift(); |
| 8 |
}else { |
| 9 |
particle = new Object(); |
| 10 |
fireParticles.push( particle ); |
| 11 |
} |
| 12 |
|
| 13 |
particle.x = uint( Math.random() * frame.width * 0.1 ) + anchors[anchorPoint]; |
| 14 |
particle.y = frame.bottom; |
| 15 |
particle.life = 70 + uint( Math.random() * 30 ); |
| 16 |
particle.size = 5 + uint( Math.random() * 10 ); |
| 17 |
|
| 18 |
if(particle.size > 12){ |
| 19 |
particle.size = 10; |
| 20 |
} |
| 21 |
particle.anchor = anchors[anchorPoint] + uint( Math.random() * 5 ); |
| 22 |
|
| 23 |
anchorPoint = (anchorPoint == 9)? 0 : anchorPoint + 1; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
// From https://code.tutsplus.com/tutorials/actionscript-30-optimization-a-practical-example--active-11295 |