Flint Particle System Forum - Animated Particle using a series of BitmapData objects Sun, 16 Oct 2011 22:25:32 +0100 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1705#Comment_1705 http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1705#Comment_1705 Mon, 29 Aug 2011 01:22:25 +0100 Makoto Animated Particle using a series of BitmapData objects http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1707#Comment_1707 http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1707#Comment_1707 Tue, 30 Aug 2011 08:30:15 +0100 Richard 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 http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1709#Comment_1709 Tue, 30 Aug 2011 23:49:27 +0100 Makoto 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 http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1710#Comment_1710 Wed, 31 Aug 2011 21:14:50 +0100 Makoto 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 http://flintparticles.org/forum/comments.php?DiscussionID=511&Focus=1730#Comment_1730 Tue, 27 Sep 2011 08:46:21 +0100 Richard
Thank you for sharing this.

Richard ]]>