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 [import]uid: 49236 topic_id: 8741 reply_id: 308741[/import]

Just rotate the emiter with the gun and sitck to your long rectangle beam image. [import]uid: 9328 topic_id: 8741 reply_id: 31876[/import]

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. [import]uid: 49236 topic_id: 8741 reply_id: 31915[/import]

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” :slight_smile: 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. [import]uid: 10504 topic_id: 8741 reply_id: 35349[/import]

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! [import]uid: 49236 topic_id: 8741 reply_id: 35462[/import]

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]

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. [import]uid: 49236 topic_id: 8741 reply_id: 35532[/import]

Hi Expressive dot com - how would I use Particle Candy to create a shooting star effect, arcing across an iPad screen? [import]uid: 94653 topic_id: 8741 reply_id: 92891[/import]

Could you illustrate this effect with an image, a sketch or a sample video? [import]uid: 10504 topic_id: 8741 reply_id: 93010[/import]

I think like a star moving in an arc across the screen, trailing particles behind it. [import]uid: 10389 topic_id: 8741 reply_id: 93183[/import]

Sorry for the delay. Yes, like Bilby says, a star shooting across a night sky with particles trailing behind it.

It’s for a children’s book, so a cute star, rather than a blazing comet. I can’t see an attachment feature on the forum here. If you have an email I can send you a picture.

Cheers
[import]uid: 94653 topic_id: 8741 reply_id: 93233[/import]

The easiest method would be to use a sprite (the star) and move it across the screen using math.cos and math.sin to move it on an arc-shaped path. Then use SetEmitterTarget to let the emitter follow that sprite. That should basically do what you described. [import]uid: 10504 topic_id: 8741 reply_id: 93246[/import]

Thanks for that. I would be using it with Kwik. Are there things to bare in mind when using Particle Candy with Kwik which uses Director Class? [import]uid: 94653 topic_id: 8741 reply_id: 93266[/import]

I am not familiar with Kwik, but whenever working with “scene changing” libraries like Director etc., you should create your scene at first, then create any particle stuff. When switching from one scene to another, first remove all particle stuff, then switch to another scene.

There is a sample included to demonstrate how to use Particle Candy with Corona Storyboard, see Sample Codes -> Sample_Storyboard. [import]uid: 10504 topic_id: 8741 reply_id: 93272[/import]