Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
How do I?: createRectangleParticlesFromBitmapData, working out how to animate these particles:
Bottom of Page1 to 2 of 2
-
- CommentAuthorrez1n
- CommentTimeOct 14th 2009
I'm trying to figure out how I can animate the particles I have created using createRectangleParticlesFromBitmapData
here is my code:
----------------------------------------------------------------
var bitMap = new Bitmap(new Owl(0,0))
var emitter:Emitter2D = new Emitter2D();
var particles:Array = Particle2DUtils.createRectangleParticlesFromBitmapData( new Image1(384,255), 50, emitter.particleFactory, 56, 47 );
var emitter_counter:TimePeriod = new TimePeriod(30,4);
emitter.counter = emitter_counter;
var emitter_action0:Move = new Move();
var emitter_action1:Age = new Age();
var emitter_action2:RandomDrift = new RandomDrift(500,200);
var emitter_action3:Fade = new Fade(1,0);
emitter.addAction(emitter_action0);
emitter.addAction(emitter_action1);
emitter.addAction(emitter_action2);
emitter.addAction(emitter_action3);
var emitter_initializer2:Lifetime = new Lifetime(0.5,1);
var emitter_initializer7:Position = new Position(new DiscSectorZone(new Point(10,10),10,0,360,0));
var emitter_initializer8:Velocity = new Velocity(new DiscSectorZone(new Point(137,123),10,0,360,0));
emitter.addInitializer(emitter_initializer2);
emitter.addInitializer(emitter_initializer7);
emitter.addInitializer(emitter_initializer8);
emitter.addInitializer(new SharedImages([particles])); // if i put 'bitMap' in here it works, however its just 1 bitmap not an array of them like 'particles'
var renderer:BitmapRenderer = new BitmapRenderer(new Rectangle(0, 0, 530, 430));
renderer.addEmitter(emitter);
emitter.start();
addChild(renderer);
----------------------------------------------------------------
I want it to cycle 30 times, or the length of the particles array, through the different particles that i created.
The animation works if i put in the 1 bitmap image but when i try to send it the Array of particles its not working, I know im not seeing somthing here. -
- CommentAuthorRichard
- CommentTimeOct 19th 2009 edited
The particles array doesn't contain images, it contains complete particles. To use these particles you add them directly to the emitter, like thisemitter.addExistingParticles( particles, true );
You'll want to remove the SharedImage imitializer and the Position initializer since the particles are already positioned according to the image layout. Also, remove the counter because you don't want to make any more particles.
See the Explode Image example to see it in action.
1 to 2 of 2
