Hi, I created a particle emitter using newEmitter() and I want to detect possible collisions of particles with other display objects using physics module. Is this possible?
Emitter particles cannot be manipulated and cannot be given bodies.
If you need particles with physics:
https://docs.coronalabs.com/api/library/physics/newParticleSystem.html
Even then, I’m not sure individual particles can have collision listeners.
There is however a third choice:
Thanks for explanation. Actually, I have created a demo with a spaceship that fires bullets. I have implemented the weapons with custom code, but then I thought to use a particle system for it. Do you find a good idea to use a particle system for this reason? Also, the external library you mentioned can do the trick?
Sure, you could use a particle emitter as a projectile, but you’d probably have more success firing a transparent ‘bullet’ with a particle emitter following it via an enterFrame() listener (or some other similar solution).
-Ed
Can you elaborate a little more on the idea you proposed with transparent projectile? This is what I understood: Fire the transparent projectile, which will have a particle emitter following it, but the projectile is the object that detects any collision so it has to be always in front of others particles. So what if an enemy display object avoid the first (transparent) projectile and hit in the middle of emitter particles?
I’m afraid I can’t the question is too open and I don’t want to code up a emitter example just to show you.
That said, I’ll answer briefly
-
Not following. Right on it. Following == tracking position in this case.
– May contain typos – local physics = require “physics” physics.start() – Fake bullet – local bullet = display.newCircle( 100, 100, 20 ) bullet.alpha = 0.5 – Not entirely hidden so you can see the ‘fake emitter’ tracks it exactly. bullet:setFillColor(1,0,0) physics.addBody( bullet ) – Will fall now – Not an emitter, just a rectangle to show concept of one object tracking another – local emitter = display.newRect( 0, 0, 10, 10 ) emitter.myBullet = bullet function emitter.enterFrame( self ) self.x = self.myBullet.x self.y = self.myBullet.y end Runtime:addEventListener(“enterFrame”,emitter)
-
Your hypothetical scenario… not going to happen. See #1
Also, I hope you’re aware I have tons of samples and answers
- https://github.com/roaminggamer/CoronaGeek
- https://github.com/roaminggamer/RG_FreeStuff (download entire repository)
- (VIDEO FROM THIS SET OF MANY MANY ANSWERS) https://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd/2015%20Answer%20Packs
- https://github.com/roaminggamer/SSKLegacy
https://www.youtube.com/watch?v=JCzrjNeNovs
PS - This video uses my own ‘custom’ emitter. Not any of the prior three options we discussed. The concept could be applied to any of the three options though.
Thank you very much for your time, I will sure dive into your tuts to refresh my skills. 
Emitter particles cannot be manipulated and cannot be given bodies.
If you need particles with physics:
https://docs.coronalabs.com/api/library/physics/newParticleSystem.html
Even then, I’m not sure individual particles can have collision listeners.
There is however a third choice:
Thanks for explanation. Actually, I have created a demo with a spaceship that fires bullets. I have implemented the weapons with custom code, but then I thought to use a particle system for it. Do you find a good idea to use a particle system for this reason? Also, the external library you mentioned can do the trick?
Sure, you could use a particle emitter as a projectile, but you’d probably have more success firing a transparent ‘bullet’ with a particle emitter following it via an enterFrame() listener (or some other similar solution).
-Ed
Can you elaborate a little more on the idea you proposed with transparent projectile? This is what I understood: Fire the transparent projectile, which will have a particle emitter following it, but the projectile is the object that detects any collision so it has to be always in front of others particles. So what if an enemy display object avoid the first (transparent) projectile and hit in the middle of emitter particles?
I’m afraid I can’t the question is too open and I don’t want to code up a emitter example just to show you.
That said, I’ll answer briefly
-
Not following. Right on it. Following == tracking position in this case.
– May contain typos – local physics = require “physics” physics.start() – Fake bullet – local bullet = display.newCircle( 100, 100, 20 ) bullet.alpha = 0.5 – Not entirely hidden so you can see the ‘fake emitter’ tracks it exactly. bullet:setFillColor(1,0,0) physics.addBody( bullet ) – Will fall now – Not an emitter, just a rectangle to show concept of one object tracking another – local emitter = display.newRect( 0, 0, 10, 10 ) emitter.myBullet = bullet function emitter.enterFrame( self ) self.x = self.myBullet.x self.y = self.myBullet.y end Runtime:addEventListener(“enterFrame”,emitter)
-
Your hypothetical scenario… not going to happen. See #1
Also, I hope you’re aware I have tons of samples and answers
- https://github.com/roaminggamer/CoronaGeek
- https://github.com/roaminggamer/RG_FreeStuff (download entire repository)
- (VIDEO FROM THIS SET OF MANY MANY ANSWERS) https://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd/2015%20Answer%20Packs
- https://github.com/roaminggamer/SSKLegacy
https://www.youtube.com/watch?v=JCzrjNeNovs
PS - This video uses my own ‘custom’ emitter. Not any of the prior three options we discussed. The concept could be applied to any of the three options though.
Thank you very much for your time, I will sure dive into your tuts to refresh my skills. 