FX Field Events and event.Particle

event.Particle is an Handle of the particle. Read event.Particle.x or event.Particle.y to determine the particle’s current position, for example.

Got it.

What if want to access other properties (scaleMax,…o of my particle I defined

Particles.CreateParticleType ("MyParticleType1", { imagePath = "arrow.png", imageWidth = 32, mycustomdata = 1 -- I want to access this one ....... [import]uid: 9328 topic_id: 33808 reply_id: 333808[/import]

No one in this forum ?

Talking about Particle Event and listener functions when any of their emitted particles have been killed (expired) : I"d like to add some parameters (other than .scale,… : something like event.mydata) , how could I tweak the library ?
[import]uid: 9328 topic_id: 33808 reply_id: 136309[/import]

Hello Antheor!

I’m using physics particles in my game and you can use custom properties for those at least.
You could do something like this:

 Particles.CreateParticleType ("MyLaserParticle",   
 {  
 imagePath = "assets/particles/redlaser.png",  
 imageWidth = 8,   
 imageHeight = 15,   
 velocityStart = 600,   
 autoOrientation = true,   
 killOutsideScreen = false,   
 lifeTime = 3000,   
 alphaStart = 0.8,   
 blendMode = "add",  
 colorStart = {255, 0, 0},  
 -- APPLY PHYSICS:  
 PhysicsMaterial = { density = 0, friction = 0, bounce = 0 },  
 PhysicsProperties = {   
 filter = {},   
 isFixedRotation = true,   
 isSleepingAllowed = false,   
 bodyType = "dynamic",   
 isSensor = true,   
 ID = object.ammoID, -- ID for the ammo (for example "playerAmmo")  
 damage = object.damage, -- custom property: damage for the particle type  
 dieOnImpact = true, -- custom property: destroy particle on impact  
 gravityScale = 0   
 }  
 } )  
  
  
 local Particle = nil  
 -- check who's particle this is   
 if event.object1.ID == "playerAmmo" then Particle = event.object1; end;  
 if event.object2.ID == "playerAmmo" then Particle = event.object2; end;  
  
 -- check if player's particle hits the enemy...  
  
 -- reduce enemy health  
 enemy.health = enemy.health - Particle.damage -- here we use custom property "damage"  

Hope this helps!

Br,

Kalle [import]uid: 55867 topic_id: 33808 reply_id: 136314[/import]

Thx for the answer, I’ll check this solution :slight_smile:

Actually, I 'd like to use those physic particles with the SetEmitterListener. Any idea how could I do this ?

In particle candy sample code (as in yours, iy seems), it uses a Runtime:addEventListener( “collision”, onCollision ).
[import]uid: 9328 topic_id: 33808 reply_id: 136320[/import]

No one in this forum ?

Talking about Particle Event and listener functions when any of their emitted particles have been killed (expired) : I"d like to add some parameters (other than .scale,… : something like event.mydata) , how could I tweak the library ?
[import]uid: 9328 topic_id: 33808 reply_id: 136309[/import]

Hello Antheor!

I’m using physics particles in my game and you can use custom properties for those at least.
You could do something like this:

 Particles.CreateParticleType ("MyLaserParticle",   
 {  
 imagePath = "assets/particles/redlaser.png",  
 imageWidth = 8,   
 imageHeight = 15,   
 velocityStart = 600,   
 autoOrientation = true,   
 killOutsideScreen = false,   
 lifeTime = 3000,   
 alphaStart = 0.8,   
 blendMode = "add",  
 colorStart = {255, 0, 0},  
 -- APPLY PHYSICS:  
 PhysicsMaterial = { density = 0, friction = 0, bounce = 0 },  
 PhysicsProperties = {   
 filter = {},   
 isFixedRotation = true,   
 isSleepingAllowed = false,   
 bodyType = "dynamic",   
 isSensor = true,   
 ID = object.ammoID, -- ID for the ammo (for example "playerAmmo")  
 damage = object.damage, -- custom property: damage for the particle type  
 dieOnImpact = true, -- custom property: destroy particle on impact  
 gravityScale = 0   
 }  
 } )  
  
  
 local Particle = nil  
 -- check who's particle this is   
 if event.object1.ID == "playerAmmo" then Particle = event.object1; end;  
 if event.object2.ID == "playerAmmo" then Particle = event.object2; end;  
  
 -- check if player's particle hits the enemy...  
  
 -- reduce enemy health  
 enemy.health = enemy.health - Particle.damage -- here we use custom property "damage"  

Hope this helps!

Br,

Kalle [import]uid: 55867 topic_id: 33808 reply_id: 136314[/import]

Thx for the answer, I’ll check this solution :slight_smile:

Actually, I 'd like to use those physic particles with the SetEmitterListener. Any idea how could I do this ?

In particle candy sample code (as in yours, iy seems), it uses a Runtime:addEventListener( “collision”, onCollision ).
[import]uid: 9328 topic_id: 33808 reply_id: 136320[/import]