Flint Particle System Forum - Explode Image + Logo Tween 2011-10-17T02:07:02+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Explode Image + Logo Tween http://flintparticles.org/forum/comments.php?DiscussionID=497&Focus=1663#Comment_1663 2011-07-09T20:57:22+01:00 2011-07-31T18:12:54+01:00 jungalero http://flintparticles.org/forum/account.php?u=516 Forgive me if this has been covered, but I haven't found the exact approach I'm looking for. Put simply, I want to combine the explode image and logo tween examples so I have an image that tweens ...
Put simply, I want to combine the explode image and logo tween examples so I have an image that tweens to a BitmapDataZone on click.

However, the emitter populated with createRectangleParticlesFromBitmapData doesn't seem to respond to TweenToZone. I'm sure I'm missing something, but what?

import org.flintparticles.common.events.EmitterEvent;
import org.flintparticles.common.particles.Particle;
import org.flintparticles.twoD.actions.DeathZone;
import org.flintparticles.twoD.actions.Explosion;
import org.flintparticles.twoD.actions.Move;
import org.flintparticles.twoD.actions.MouseGravity;
import org.flintparticles.twoD.actions.GravityWell;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.particles.Particle2DUtils;
import org.flintparticles.twoD.renderers.DisplayObjectRenderer;
import org.flintparticles.twoD.zones.RectangleZone;
import org.flintparticles.twoD.actions.TweenToZone;
import org.flintparticles.twoD.zones.BitmapDataZone;


var explosion:Explosion;
var bitmap:BitmapData = new Image1( 384, 255 );
var particlesImage:BitmapData = new ParticlesImage( 320, 80 );

var emitter:Emitter2D = new Emitter2D();
emitter.addAction( new Move() );
emitter.addAction( new DeathZone( new RectangleZone( -10, -10, 510, 360 ), true ) );
prepare();

var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
addChild( renderer );
renderer.addEmitter( emitter );
emitter.start();

stage.addEventListener( MouseEvent.CLICK, explode, false, 0, true );
emitter.addEventListener( EmitterEvent.EMITTER_EMPTY, prepare );

function prepare( event:EmitterEvent = null ):void
{
if( explosion )
{
emitter.removeAction( explosion );
explosion = null;
}
var particles:Vector.<Particle> = Particle2DUtils.createRectangleParticlesFromBitmapData( bitmap, 8, emitter.particleFactory, 0, 0 );
emitter.addParticles( particles, false );
}

function explode( ev:MouseEvent ):void
{
var p:Point = renderer.globalToLocal( new Point( ev.stageX, ev.stageY ) );

if (!explosion) {
explosion = new Explosion( 2,p.x, p.y, 500 );
//emitter.addAction( explosion );
//emitter.addAction(new MouseGravity(50, stage, 50));
emitter.addAction( new TweenToZone( new BitmapDataZone( particlesImage, 40, 60 ) ) );
} else {
//emitter.addAction( new GravityWell( 50, p.x, p.y ) );
}
}
]]>
Explode Image + Logo Tween http://flintparticles.org/forum/comments.php?DiscussionID=497&Focus=1682#Comment_1682 2011-07-31T18:11:29+01:00 2011-10-17T02:07:02+01:00 Richard http://flintparticles.org/forum/account.php?u=1 This doesn't work as you've coded it because TweenToZone requires the particle to have a lifetime and an age action. The easiest way to achieve what you want is like this import ...
import org.flintparticles.common.actions.Age;
import org.flintparticles.common.initializers.Lifetime;
import org.flintparticles.common.particles.Particle;
import org.flintparticles.twoD.actions.TweenToZone;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.particles.Particle2DUtils;
import org.flintparticles.twoD.renderers.DisplayObjectRenderer;
import org.flintparticles.twoD.zones.BitmapDataZone;

var bitmap : BitmapData = new Image1( 384, 255 );
var particlesImage : BitmapData = new ParticlesImage( 320, 80 );
var emitter : Emitter2D = new Emitter2D();
emitter.addInitializer( new Lifetime( 6 ) );
emitter.addAction( new Age() );
emitter.addAction( new TweenToZone( new BitmapDataZone( particlesImage, 40, 60 ) ) );

var particles : Vector.<Particle> = Particle2DUtils.createRectangleParticlesFromBitmapData( bitmap, 8, emitter.particleFactory, 0, 0 );
emitter.addParticles( particles, true );

var renderer : DisplayObjectRenderer = new DisplayObjectRenderer();
addChild( renderer );
renderer.addEmitter( emitter );

stage.addEventListener( MouseEvent.CLICK, start, false, 0, true );

function start( ev : MouseEvent ) : void
{
emitter.start();
}
]]>