Laser or plasma beam effect. How?

Hi guys,

I just bought particle candy (and text candy...by accident...don't ask!) and I am loving it so far. It will take a million years to make these effects by hand. Anyway I need to simulate a laser or plasma gun firing. Basically I am thinking of a short burst of laser (or more likely a plasma burst) that would travel in the direction of the target. A little like AA tracer fires. I will guess I cannot use a rectangle image of small tracers since if I rotate the gun, the tracer particle will not rotate and would like a straight short line going sideways.

Not much if I am making any sense but would love to hear from the pro here. Of course I am experimenting with it it since I just got particle candy.

Thanks guys:)

Mo

Just rotate the emiter with the gun and sitck to your long rectangle beam image.

Thanks Antheor. It works! I really need to understand how particle candy uses those images to build effects. I always thought particle engine emit small dots or pixels or different colors or alpha. It seems that particle candy is more likely small version of the images we provide. Am I right in my thinking? Will love to find out the particle engine work with those images. Not at the detail level but just the concept used..

Thanks again. I appreciated you taking the time.

Mo.

Please excuse the delayed answer lemsim, we've been abroad and out of office during april (which may happen every few months).

So, to your post: particles are not only "dots" or "small rectangles" :-) In fact, the kind of image you use for your particles, is most important. For most "common" particle effects like smoke, flames, explosions etc., it is a good practice to use a "fluffy", transparent, cloud image. It's important to provide a rounded and irregular shape, especially for cloud and fire effects, otherwise you would see the rectangular nature of the images used.

BTW, we just added additive blending to the latest Particle Candy version (which will be out within the next couple of days) which is ideal to be used with your laser particles.

Welcome back!

Thank you for the info. I have a follow up question if I may. I am working on a space shooter game. I am trying to simulate the view from the cockpit (HUD view) and the laser gun shooting in front of the player. To that effect I want the laser beam to start at the bottom of the screen (center) and go toward the a moving gun cross on the screen.

Now the question! Do you think Particle Candy is suitable for this of effect or should I stick to just draw a line of different color (to simulate a laser beam ala Stars Wars)? The reason I say that is that I need the laser beam (or even a beam particle gun) to reduce in size overtime so to simulate a 3D effect (the beam size get smaller with distance to the player)

I am not sure if I am making any sense! But I am sure enjoying experimenting with Particle Candy:)

So my experiment on the laser beam are promising but one of the problem I have is the particle do not go down in size with time nor I can stop them when they reach the gun cross. They either do not make it to the moving gun cross or simply pass thru it and the effect is shot. I am using the lifetime to try timing the length of the laser beam with no much success...

Thanks again for a super product!

Mo.

ps: Can't wait for what's in store in the candy's store!

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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 )

Hi.

WOW! a full example! I was not expecting this. Thank you so much. Even so I think you right that a simple transition would be better in this case, I learned quite a bit on how to use PC. Including the "scaleOutSpeed" parameter being negative.

Thank you again for an amazing piece of software.

Mo.

views:1928 update:2011/10/14 9:11:21
corona forums © 2003-2011