The main goal is to keep the library’s performance as good as possible, so it’s wise to add features that can be used in a wide range of games only.
But you could loop through your particles and check the distance between a particle and any given x/y coordinate. If the distance between the particle’s coord and this x/y coordinate (which could be the center of an imaginary, particle destroying area) is lower than the areas’s radius, the particle is inside this area. Then you can manipulate the life energy of the particle by your own. Here is a quick sample:
[lua]-- LOOP THROUGH ALL PARTICLES AND CHECK IF A PARTICLE
– IS INSIDE AN IMAGINARY FIELD THAT DAMAGES A PARTICLE.
– PARTICLE GETS DESTROYED ONCE THE DAMAGE REACHES A
– VALUE OF 100.
local Particle, dx, dy
local fieldCenterX = 200
local fieldCenterY = 200
local fieldRadius = 50
local sqrt = math.sqrt
local now = system.getTimer()
local numParticles = Particles.GetMaxParticles()
– LOOP THROUGH PARTICLES
for i = 1, numParticles do
Particle = Particles.GetParticle(i)
– PARTICLE EXISTS?
if Particle ~= nil then
– WHAT PARTICLE TYPE TO LOOK FOR?
if Particle.PType.name == “MyParticlesToDamage” then
– GET DISTANCE BETWEEN PARTICLE AND FIELD’S CENTER
dx = Abs( fieldCenterX - Particle.x )
dy = Abs( fieldCenterY - Particle.y )
– PARTICLE IS INSIDE THIS FIELD’S RADIUS?
if sqrt ( (dx*dx) + (dy*dy) ) < fieldRadius then
Particle.damage = Particle.damage + 0.1
– KILL THIS PARTICLE?
if Particle.damage >= 100 then Particle.killTime = now
end
end
end
end[/lua]
[import]uid: 10504 topic_id: 5076 reply_id: 19686[/import]