Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Particle Emitter for Explosion?
Started by Xorcist Jul 31 2019 02:29 PM

5 replies to this topic
particle emitter explosion
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Xorcist

[GLOBAL: userInfoPane.html]
Xorcist
  • Observer

  • 17 posts
  • Corona SDK

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?



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 938 posts
  • Corona SDK

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 http://particle2dx.com/ for what kind of explosion effects you could create with particles. Then, just load them into Corona (see documentation).



[TOPIC: post.html]
#3

Xorcist

[GLOBAL: userInfoPane.html]
Xorcist
  • Observer

  • 17 posts
  • Corona SDK

Thanks that site helped a lot.



[TOPIC: post.html]
#4

Xorcist

[GLOBAL: userInfoPane.html]
Xorcist
  • Observer

  • 17 posts
  • Corona SDK

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).



[TOPIC: post.html]
#5

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 938 posts
  • Corona SDK

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.



[TOPIC: post.html]
#6

Xorcist

[GLOBAL: userInfoPane.html]
Xorcist
  • Observer

  • 17 posts
  • Corona SDK

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.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: particle, emitter, explosion