Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorericr
- CommentTimeMay 8th 2008 edited
In Flint 1.0.2 [at least] developers must store a reference to each Emitter object they instantiate. This is due to the fact that no reference to the Emitter is kept in the Display Hierarchy. Currently, as is visible in all demos, we get the following scenario:
Emitter -> Renderer.
Display Hierarchy -> Renderer.
Nowhere does a reference to the Emitter get stored.
I would make a motion for a re-implementation of the Emitter/Renderer setup. I would suggest [naïvely] adding an _emitters:Array field to the Renderer class. This kind of makes sense, too. Emitters are simply the logic behind the Renderer. Why not have two Renderers reference a single emitter (or multiple, for that matter)? The only thing that would need to change in the Emitter class is the following line:_renderer.renderParticles( _particles );
Which could change to:dispatchEvent( new FlintEvent( FlintEvent.PARTICLES_UPDATED ) );
(Alternatively you could use the ENTER_FRAME event with the Renderers and mess around with priorities or rely on the fact that you might be one frame behind the emitter... either way you're fine, really.)
Adding an emitter to the renderer would have the effect of registering the renderer for that "PARTICLES_UPDATED" event (as well as storing a reference to the Emitter in the renderer object, which is added to the Display Hierarchy and thus not a candidate for garbage collection).
Current Workaround: Store a reference to your Emitter objects as a Class variable (gah). -
- CommentAuthorericr
- CommentTimeMay 8th 2008
Note: I would not advocate a circular reference (link the Emitter to the Renderer and the Renderer to the Emitter) as that would just increase the likeliness of memory leaks in peoples' programming. -
- CommentAuthorRichard
- CommentTimeMay 8th 2008 edited
Yes, there is a bug in the examples. I've now corrected them all to keep a reference to the emitter to prevent garbage collection (although, strangely, they all worked anyway - the vagaries of Flash's garbage collector). Thank you for pointing it out.
I don't, however, consider this a bug in the Emitter. Any object in flash is garbage collected if there are no references to it. An emitter is no different to other objects in this respect.
I am planning a more substantial restructuring of the relationship between the renderer and the emitter, to coincide with the release of the 3D version of Flint (this version will still support 2d as well).
The changes will allow multiple renderers to display a single emitter and multiple emitters to be displayed by a single renderer. I'll write more about it and we can have a discussion when I have an alpha version to show. -
- CommentAuthorericr
- CommentTimeMay 8th 2008
Fantabulous! I can't wait to hear about the upcoming changes! The new functionality sounds both efficient and extremely useful. :)
I agree that this isn't a bug in the Emitter. It is merely an oddity resulting from the current architecture.
1 to 4 of 4
