Rain animation and (or) other particles

Again, I need a help. I need rain animation or effect. Is there any variants for free? My project has little budget and add-ons like ParticleCandy are so expensive for me.
Thank you.

P.S. I’m Android developer. [import]uid: 99327 topic_id: 17093 reply_id: 317093[/import]

take a look at the code sharing section. you can find some examples here how to handle particles. I added a simple particle system myself, take a look. you should get the idea:

http://developer.anscamobile.com/code/simple-particle-explosion

-finefin [import]uid: 70635 topic_id: 17093 reply_id: 64245[/import]

canupa.com thank you so much! It is really good free variant for me. But how to activate particles, for example when touching object?
Yes, I’m newbie. [import]uid: 99327 topic_id: 17093 reply_id: 64248[/import]

try and evaluate Jeff’s GrafittiParticleSystem, that might be slightly more in your budget in comparison to Particle Candy.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17093 reply_id: 64249[/import]

kingko96, what I’ve done is the simpliest approach, I guess. If you need something more powerful, use the module JayantV suggested.

as for your question: call

explosion (theX, theY)  

to emit particles at the x/y coordinates you send as parameters.
If you need a running example, try this http://developer.anscamobile.com/code/simple-particle-explosion#comment-42115

-finefin
[import]uid: 70635 topic_id: 17093 reply_id: 64252[/import]

I understand that, but how to loop them, so they can go from up part of screen like rain falling. Should I use static invisible object from which these particles will generate? [import]uid: 99327 topic_id: 17093 reply_id: 64254[/import]

@kingko96,
you can attempt this by yourself, however since you are starting out, I would recommend that you try a proven library that does what you want. This is just a suggestion, the decision is till yours.

See if you can understand this,

What you are after is called a particle emitter. The way it functions is it like a tap, once you turn it on, it keeps emitting particles, and when you turn it off, it stops. So that is how it loops.

There are lots of sites that will offer you information on how to make a particle emitter, then it is all about adapting that to Corona.

Hope that helped,

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17093 reply_id: 64255[/import]

I don’t know… I recommend to use a simple implementation first.
Instead of a “black box”-module you should learn the principles, then you can go on implementing 3rd party stuff. but maybe it’s just my way of learning – as JayantV wrote: you decide.

however, take my example, but instead of using an onTouch event,
use an enterFrame loop:

  
-- THE EXPLOSION FUNCTION  
local particles = {} -- particle table  
local function explosion (theX, theY, blood) -- blood is BOOL  
 local particleCount = 3 -- number of particles per explosion   
 for i = 1, particleCount do  
 local theParticle = {}  
 theParticle.object = display.newRect(theX,theY,3,3)  
 if blood == true then  
 theParticle.object:setFillColor(250,0,0)  
 end  
 theParticle.xMove = math.random (10) - 5  
 theParticle.yMove = math.random (5) \* - 1  
 theParticle.gravity = 0.5  
 table.insert(particles, theParticle)  
 end  
end  
   
   
-- PARTICLES MOVING  
function animation ()  
 for i,val in pairs(particles) do  
 -- move each particle  
 val.yMove = val.yMove + val.gravity  
 val.object.x = val.object.x + val.xMove  
 val.object.y = val.object.y + val.yMove  
  
 -- remove particles that are out of bound   
 if val.object.y \> display.contentHeight or val.object.x \> display.contentWidth or val.object.x \< 0 then   
 val.object:removeSelf();  
 particles [i] = nil  
 end   
 end  
end  
   
-- NO TOUCH! enter frame!  
   
function emitter ()  
  
 local rndX = math.random (display.contentWidth)  
 explosion (rndX, -100)  
  
end  
   
 Runtime:addEventListener( "enterFrame", animation)  
 Runtime:addEventListener( "enterFrame", emitter )  
  

you should tweak the animation function to make it look like rain. right now it looks quite chaotic because the effect is based on explosions…

-finefin [import]uid: 70635 topic_id: 17093 reply_id: 64263[/import]