Flint Particle System Forum - Animated Particle using a series of BitmapData objects 2011-10-16T22:30:27+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1705#Comment_1705 2011-08-29T01:22:25+01:00 2011-10-16T22:30:27+01:00 Makoto http://flintparticles.org/forum/account.php?u=360 I found that I could create an animated particle using a MovieClip with a series of frames containing the animation along with the displayObjectRenderer. Now while this works, I fear that it could ... Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1707#Comment_1707 2011-08-30T08:30:15+01:00 2011-10-16T22:30:27+01:00 Richard http://flintparticles.org/forum/account.php?u=1 You'll need to customise the renderer to do this, but it shouldn't be too difficult. Take a look at the source code for the BitmapRenderer class, in particular the drawParticle method. You could ... source code for the BitmapRenderer class, in particular the drawParticle method. You could create a custom renderer by extending the BitmapRenderer and overriding the drawParticle method (you shouldn't need to touch any other methods). The image property of the particle can be any object so make it a custom bitmap animation class and draw the current frame, and step to the next frame, in the drawParticle method of your renderer.]]> Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1709#Comment_1709 2011-08-30T23:49:27+01:00 2011-10-16T22:30:27+01:00 Makoto http://flintparticles.org/forum/account.php?u=360 I'm assuming by your response that I'm correct in assuming that this method of animated particles will indeed be faster than the MovieClip route, yes? Also, another reason I'm trying this method is ... Also, another reason I'm trying this method is that my animation is derived from a sprite sheet that I divide up into BitmapData objects at runtime via copyPixels.
My intent here is to get the fastest possible method of rendering animated particles and am wondering if this route will provide a definite speed increase.
My attempts thus far have been at the particle level where I was using the the emitter's EMITTER_UPDATED event to step each particle's animation but haven't really noticed a speed increase.
I'll give your method a go but wouldn't it be faster to just draw the BitmapData directly to the canvas and bypass code that has to manage another object?]]>
Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1710#Comment_1710 2011-08-31T21:14:50+01:00 2011-10-16T22:30:27+01:00 Makoto http://flintparticles.org/forum/account.php?u=360 Well here's the modification I came up with and it seems to faster than my other attempts. I basically pass an Object of arrays containing the BitmapData sequences to the Renderer and use the ... I basically pass an Object of arrays containing the BitmapData sequences to the Renderer and use the particle's dictionary to hold total frames, current frame, and type (a reference to which animation sequence in the Object passed into the Renderer).
I don't know for sure if this increases performance or not but it seems in theory that it should.

package org.flintparticles.twoD.renderers
{
import org.flintparticles.twoD.particles.Particle2D;

import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.display.DisplayObject;

public class AnimatedBitmapRenderer extends BitmapRenderer
{
private var _bitmaps:Object;

public function AnimatedBitmapRenderer( canvas:Rectangle, BMDs:Object, smoothing:Boolean = false )
{
super( canvas, smoothing );
_bitmaps = BMDs;
}

override protected function drawParticle( particle:Particle2D ):void
{
var image = particle.image;
var matrix:Matrix;
if(particle.dictionary.TYPE){
particle.dictionary.CFRAME++;
if(particle.dictionary.CFRAME > particle.dictionary.FRAMES) particle.dictionary.CFRAME = 0;

matrix = new Matrix();
matrix.translate( -(_bitmaps[particle.dictionary.TYPE][0].width * 0.5), -(_bitmaps[particle.dictionary.TYPE][0].height * 0.5) );
matrix.rotate(particle.rotation);
matrix.scale(particle.matrixTransform.a, particle.matrixTransform.d);
matrix.translate( particle.matrixTransform.tx, particle.matrixTransform.ty );

image = _bitmaps[particle.dictionary.TYPE][particle.dictionary.CFRAME];
} else {
matrix = particle.matrixTransform;
}
matrix.translate( -_canvas.x, -_canvas.y );
_bitmapData.draw( image, matrix, particle.colorTransform, DisplayObject( particle.image ).blendMode, null, _smoothing );
}
}
}]]>
Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1730#Comment_1730 2011-09-27T08:46:21+01:00 2011-10-16T22:30:27+01:00 Richard http://flintparticles.org/forum/account.php?u=1 Hi Makoto Thank you for sharing this. Richard
Thank you for sharing this.

Richard]]>