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.
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
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.
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
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.
try and evaluate Jeff's GrafittiParticleSystem, that might be slightly more in your budget in comparison to Particle Candy.
cheers,
?:)
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
1 | explosion (theX, theY) |
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?
@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,
?:)
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:
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 | -- 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 ) |