Flint Particle System Forum - Explode Image + Logo Tween Mon, 17 Oct 2011 02:02:30 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Explode Image + Logo Tween http://flintparticles.org/forum/comments.php?DiscussionID=497&Focus=1663#Comment_1663 http://flintparticles.org/forum/comments.php?DiscussionID=497&Focus=1663#Comment_1663 Sat, 09 Jul 2011 20:57:22 +0100 jungalero
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 http://flintparticles.org/forum/comments.php?DiscussionID=497&Focus=1682#Comment_1682 Sun, 31 Jul 2011 18:11:29 +0100 Richard
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();
}
]]>