Flint Particle System Forum - Explosion using MovieClips as particles2011-12-12T00:55:58+00:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
Explosion using MovieClips as particleshttp://flintparticles.org/forum/comments.php?DiscussionID=440&Focus=1499#Comment_14992011-01-04T03:48:41+00:002011-01-04T18:05:56+00:00venhttp://flintparticles.org/forum/account.php?u=447
I'm working on a puzzle game that has an 8x8 grid of MovieClip objects. When the game is over I wanted to explode the objects from the center of the board. Here is the working code; in your FLA ...
-Ven
public class FlintExpl extends MovieClip { var emitter:Emitter2D = new Emitter2D();
function FlintExpl() { // setup display init();
// wait for click stage.addEventListener( MouseEvent.CLICK, mouseClick ); }
// handle mouse click, start emitter when mouse is clicked function mouseClick( e:MouseEvent ) { emitter.start(); }
// create a grid of blocks (jewels) 8x8 and then setup for explosion in the middle of grid function init() { // here we create an array of our movieclip objects to be use as particles, ideally this would // already be filled before passing to the explosion handler. var jewels:Array = new Array();
// setup for grid const INIT_X = 100; // grid x,y corner point const INIT_Y = 100;
var ix:int = INIT_X; // used in setting starting points for grid rows, cols var iy:int = INIT_Y;
var height:int = 20; // dimensions of object var width:int = 20; const SPC = 3; // spacing between objects
for ( var i:int = 0; i < 8; i++ ) { for ( var j:int = 0; j < 8; j++ ) { var obj:Jewel = new Jewel;
// add renderer var renderer:DisplayObjectRenderer = new DisplayObjectRenderer(); renderer.addEmitter( emitter); addChild( renderer );
// set up the explosion - good to play with explosion strenght, depth and epsilon // the object's origin is in the center, so need to offsets in x/y to get to center of grid // check Explosion constructor documentation emitter.addAction(new Explosion(1,(INIT_X + (width + SPC) * 4) - ((width+SPC)/2), (INIT_Y + (height + SPC) * 4 ) - ((height+SPC)/2), 300, 10)); // set up explosion emitter.addAction( new Move() ); // set to objects to move
// TODO: here we can limit how far out the explosions will go
// start emitter when mouse is clicked // emitter.start(); } } }]]>