You can scale over time -using a scaleOutSpeed value of -0.5, for example, means that the particle will shrink to half of its size during one second.
However, your effect could be done easily using only transitions and simple collision checks, which would probably more efficient than using Particle Candy (keep in mind that Particle Candy is primarily made for visual effects).
But if you’d like to use Particle Candy to do so -here is how you could do this:
Download this image and name it “laser.png”
main.lua
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
– LOAD PARTICLE LIB
local Particles = require(“lib_particle_candy”)
local screenW = display.contentWidth
local screenH = display.contentHeight
– CREATE ENEMY
Enemy = display.newCircle(screenW*0.5, screenH*0.4, 25)
– CREATE AN EMITTER
Particles.CreateEmitter(“E1”, screenW*0.5, screenH*1.05, 0, true, true)
– DEFINE PARTICLE TYPE PROPERTIES
Particles.CreateParticleType (“Laser”,
{
imagePath = “laser.png”,
imageWidth = 128,
imageHeight = 128,
velocityStart = 350,
killOutsideScreen = false,
lifeTime = 3000,
scaleOutSpeed = -1.6, – ADJUST THIS
blendMode = “add”,
} )
– FEED EMITTER
Particles.AttachParticleType(“E1”, “Laser”, 5, 99999,0)
– TRIGGER THE EMITTERS
Particles.StartEmitter(“E1”)
Emitter = Particles.GetEmitter(“E1”)
– MAIN LOOP
local function main( event )
– UPDATE PARTICLES
Particles.Update()
– MOVE EMITTER
Emitter.x = screenW*.5 + math.sin(system.getTimer()/800)*(screenW*.5)
– LOOP THROUGH EXISTING PARTICLES
local Particle
local numParticles = Particles.GetMaxParticles()
for i = 1, numParticles do
Particle = Particles.GetParticle(i)
if Particle ~= nil and Particle.PType.name == “Laser” then
– HIT TARGET?
if Particle.y < Enemy.y + 25 and Particle.y > Enemy.y - 25 then
if Particle.x < Enemy.x + 25 and Particle.x > Enemy.x - 25 then
– REPOSITION TARGET
Enemy.x = math.random()*screenW
end
end
end
end
end
Runtime:addEventListener( “enterFrame”, main )[/lua]
[import]uid: 10504 topic_id: 8741 reply_id: 35478[/import]