Getting an emitter to emit from a movieclip in Animate

Hi everything, I'm a newbie to ZIM but I love it already. This is probably a torturously simply question, as I'm also not a wiz at JS, but I've created an emitter based on the ZIM tutorial. What I would like to do now though is to have it triggering from the timeline of a movie clip in Animate that is itself animating along a path guide. So I imagine the logic would be to have script in the movie clip's timeline frame, first setting the emitter's location to be that of the movie clip's current position on the canvas and then an Emitter.(PLAY) call? I've been banging my head against a wall trying to get this to work, but am failing horribly. Any help would be greatly appreciated. I can share the emitter code if that helps?

1 Like

Welcome to the ZIM Forum, @Yacobserver (Jake). Thanks for the kind words.

If you want to play the emitter at certain times, then start with the emitter paused by setting startPause:true in the Emitter parameters. You can do this directly by using the ZIM DUO config object:

const emitter = new Emitter({startPaused:true});

Then when you want to play the emitter, loc() the emitter and use the spurt() method:

emitter.loc(targetObj).spurt(10);
// or loc() can alternatively use x and y.

Or something like that. Let us know if we can help further. Cheers. Possibly, depending on when you add the emitter, you may need to bring the particles container up levels above something else.

emitter.particles.top();

Ah Doctor, thanks so much for your reply. I'm still failing.
I have this code on the first frame on the root level:

const Sparkles = new Emitter ({
obj:new Poly({min:5,max:15}, 5, .6, [white,yellow]),
interval:.005,
animation:{props:{rotation:{min:180, max:360*3, negative:true}}, time:2},
gravity: 25,
force:5,
startPaused:true,
}).center();

I then have the following on another layer in frame 27 of the same timeline:
Sparkles.loc(Sparkle_Source).spurt(20);

I can only think that I'm not targeting the (targetObj) correctly. Perhaps I have to zimify it to reference it? Thanks for your help!

PS. I have a Movie Clip on the root timeline with an instance name of 'Sparkle_Source'

Yes, it does sound like a scope issue. You can use zog(Sparkles) on the line before you do the loc(). If this shows undefined in the console (F12) then it is a scope issue. If you want, you can DM me the FLA and I can take a look.