Rain Animation

Hello

Is there a sample that show how to make a rain animation like this sample: http://www.toxiclab.org/tutorial.asp?ID=151

also how can I can adjust the screen brightness with the simulator

the flash example you posted works without any scripting, it's timeline based only.

for a similar - scripted - effect, you should take a look to the code sharing section and search for "particle" effects.

as for the drop-on-ground animation you could use vector objects (display.newCircle) or sprite animations. vector objects are more generic and allow variations of the animation (speed, size, duration) while sprite animations allow better fps-performance on higher object counts...

-finefin

You should make an oval shaped white Outline that is blurred and transition it.

You can use simply transition.to(ovalShape,{time=2000,xScale=2,yScale=2,alpha=0,onComplete=function() ovalShape:removeSelf() end}) for each particle when it hits the fake-ground

(or even better make a little timer that will call a function to create 3 of these ovalShapes and transition them!)

I followed your advices and come out with this:

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
display.setStatusBar( display.HiddenStatusBar )
 
local background = display.newImage("countrySide.jpg")
local function itsRaining()
        local rainType = math.random(1,3)
        local ovalShape = display.newImage("Oval.png")
        local xPostion  = math.random(0,48) * 20
        ovalShape.x = xPostion; ovalShape.y = 0
        ovalShape:rotate(45)
        
        local function removeRainDrop(obj)
                local myCircle = display.newCircle( obj.x, obj.y, 1 )
                myCircle:setFillColor(204,255,255)
                myCircle:setStrokeColor(153,204,255) 
                myCircle.strokeWidth = 1
                myCircle:scale(1,0.25)
                
                --ovalShape:removeSelf()
                transition.to(obj,{time=00,xScale=2,yScale=2,alpha=0,onComplete=function() ovalShape:removeSelf() end}) 
                transition.to(myCircle,{time=500,xScale=4,yScale=1,alpha=1,onComplete=function() myCircle:removeSelf() end}) 
        end
        local toY = math.random(0,64)
        transition.to(ovalShape,{time=(toY * 100)/1.5,x=ovalShape.x - 200,y=toY * 10,alpha=1,onComplete=removeRainDrop})
end
Runtime:addEventListener("enterFrame",itsRaining)

Cool, i didn't think about accelerating the motion.

If there is any other advices, please let me know :)

Thank you

views:2424 update:2011/12/29 9:44:01
corona forums © 2003-2011