Flint Particle System Forum - Single Image Particles at Specific Locations Sat, 25 Dec 2010 18:53:16 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Single Image Particles at Specific Locations http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=127#Comment_127 http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=127#Comment_127 Thu, 08 May 2008 23:12:33 +0100 ericr
Let's say that when they're hit, some crazy "functionality" converts them into Flint Particles. How would, given a single Renderer object (spanning the play space, of course), one set up each Particle in the correct location with an Emitter? Is this currently possible? Would this need to be implemented possibly as a new Initializer?

Further, if the Emitter is already running, is there a way to dynamically instruct it to generate new particles? ]]>
Single Image Particles at Specific Locations http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=128#Comment_128 http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=128#Comment_128 Sat, 10 May 2008 15:00:06 +0100 Richard addDisplayObjects method in the Emitter, this will do what I think you want. ]]> Single Image Particles at Specific Locations http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=133#Comment_133 http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=133#Comment_133 Wed, 14 May 2008 22:19:07 +0100 ericr
I would wrap line 466 in an if-block. If someone never added the DisplayObject "obj" to the Display List then that will result in a null pointer exception. If they didn't add it the point would default to (0,0) which, to me, is fine.

Perhaps something like:

if(obj.parent)
{
obj.parent.removeChild( obj ); // Line 466.
}

Thoughts?

Other than that, the function looks to do exactly what I need :} ]]>
Single Image Particles at Specific Locations http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=137#Comment_137 http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=137#Comment_137 Thu, 15 May 2008 16:47:25 +0100 ericr Beyond the bug I mention above, it's not exactly what I need. It's close, though. I will modify the function until I get what I need and I'll post it here.

The problem for me in that function is that you reset the (x,y) location to the Emitter's origin point. D'oh!

The problem was on my end: I was removing the DisplayObjects from the Display List prior to adding them to the list. This caused the prior offset to disappear; the system assumed global coordinates in the localToGlobal() function call. Whoopsie!

That said, I've expanded the code "fix" I had above to the following (this is the whole function):

private function addDisplayObject( obj:DisplayObject ):void
{
var particle:Particle = _particleFactory.createParticle();
var len:uint = _initializers.length;
for ( var i:uint = 0; i < len; ++i )
{
_initializers[i].initialize( this, particle );
}
var displayObj:DisplayObject = DisplayObject( _renderer );
var r = DisplayObjectUtils.globalToLocalRotation( displayObj, DisplayObjectUtils.localToGlobalRotation( obj, 0 ) );
if (obj.parent)
{
var p = displayObj.globalToLocal( obj.localToGlobal( new Point( 0, 0 ) ) );
particle.x = p.x;
particle.y = p.y;
obj.parent.removeChild( obj );
}
else
{
particle.x = obj.x;
particle.y = obj.y;
}
particle.image = obj;
particle.rotation = Maths.asRadians( r );
_particles.unshift( particle );
_renderer.addParticle( particle );
}

That works for my purposes. I'm not sure if it's the correct default behavior (puts freshly created [read: no modifications to x/y/etc values] DisplayObjects at the renderer's origin point instead of the Stage's origin point).

Thoughts? ]]>
Single Image Particles at Specific Locations http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=142#Comment_142 http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=142#Comment_142 Mon, 19 May 2008 15:55:05 +0100 Richard Single Image Particles at Specific Locations http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=147#Comment_147 http://flintparticles.org/forum/comments.php?DiscussionID=27&Focus=147#Comment_147 Mon, 19 May 2008 23:36:21 +0100 ericr