Particle Emitter for Explosion?

Does anyone have an example of using a particle emitter for an explosion effect? I’m just learning the particle emitter system (completely new to it), but the sample emitters bundled with Corona don’t seem to show how to accomplish this.

Does it make sense to use an emitter for this? or would this be better done with a standard sprite animation?

Whether you want to use particles or sprites completely depends on your goals and you desired art style for your game.

You can check out particle2d link removed, old page is dead and new location is just spam page for what kind of explosion effects you could create with particles. Then, just load them into Corona (see documentation).

Thanks that site helped a lot.

So I did implement my explosions with an emitter, but I have a follow up question.

Is this is proper way to be inserting my emitter into my Scene (so I don’t create a memory leak):

 function scene:create(event) local sceneGroup = self.view mainGroup = display.newGroup(); sceneGroup:insert(mainGroup); emitter = display.newEmitter(emitterParams); sceneGroup:insert(emitter); end

* mainGroup, emitter, and emitterParams (loaded from a json file) are all globally declared.

** also note, I do use mainGroup for all my sprites (I just didn’t show that here).

I would avoid using globals unless necessary or unless using them is the simpler and faster way, which is rarely the case.

Like you said, in that particular sample code, your mainGroup isn’t doing anything. Inserting your emitter into the sceneGroup should be sufficient.

When I said globally, I actually meant within the scene (they are declared as local within the game.lua similar to the Getting Started example). I assume I should probably use mainGroup:insert(emitter) instead, due to the fact all my other display elements are in that group.

Whether you want to use particles or sprites completely depends on your goals and you desired art style for your game.

You can check out particle2d link removed, old page is dead and new location is just spam page for what kind of explosion effects you could create with particles. Then, just load them into Corona (see documentation).

Thanks that site helped a lot.

So I did implement my explosions with an emitter, but I have a follow up question.

Is this is proper way to be inserting my emitter into my Scene (so I don’t create a memory leak):

 function scene:create(event) local sceneGroup = self.view mainGroup = display.newGroup(); sceneGroup:insert(mainGroup); emitter = display.newEmitter(emitterParams); sceneGroup:insert(emitter); end

* mainGroup, emitter, and emitterParams (loaded from a json file) are all globally declared.

** also note, I do use mainGroup for all my sprites (I just didn’t show that here).

I would avoid using globals unless necessary or unless using them is the simpler and faster way, which is rarely the case.

Like you said, in that particular sample code, your mainGroup isn’t doing anything. Inserting your emitter into the sceneGroup should be sufficient.

When I said globally, I actually meant within the scene (they are declared as local within the game.lua similar to the Getting Started example). I assume I should probably use mainGroup:insert(emitter) instead, due to the fact all my other display elements are in that group.