Snow Graphics

Hey Guys!
So, I’ve got another question… I’m trying to make some snow fall and the snow is deleting as soon as it appears… It’s proably something simple!

Anyway Here’s the code!
~Caleb

[code]
function makesnow()
local snowfall= display.newCircle(240,200,4)
mastergroup:insert(snowfall)
snowfall:setFillColor(210,210,210)

snowfall.y= 200–20
snowfall.x= math.random(0,340)

function snowfall:enterFrame(event)
self.x= math.random(0,340)

self.y= 200
self.life=10
self.life= self.life-.1
print(self.life)
if (self.life == 0) then
Runtime:removeEventListener(“enterFrame”,self);
self:removeSelf();
end

end
Runtime:addEventListener(“enterFrame”,snowfall)
end [import]uid: 95032 topic_id: 16392 reply_id: 316392[/import]

The snow deletes immediately because there is nothing stopping line 14 from counting right the way down to 0 as fast as the device can manage.

Try calling the “self.life = self.life - .1” line inside a function, and then call the function with a timer set to trigger every x milliseconds.

Does that help? If it doesn’t make sense let me know and I’ll work something up when I can.

[import]uid: 67933 topic_id: 16392 reply_id: 61146[/import]

Thanks! I’m not sure what you mean… It’s a litle confusing. (well I am cofused… everyone else probably gets it :P) Anyway… how do I know what particle (or “snowfall”) I am doing “self.life” for in another function? Because I have multiple EventListeners, for each “snowfall”. So how do I want to make it recognize what “snowfall”'s life I am tweaking?
Thanks for the help! [import]uid: 95032 topic_id: 16392 reply_id: 61194[/import]

You can look at particle engines if that helps, it’s all the work already done for you, plus JStrahan has a really nice library which he will release soon, see his awesome rain demo.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16392 reply_id: 61212[/import]

Ok, I’ll look at that…! [import]uid: 95032 topic_id: 16392 reply_id: 61289[/import]

Me and my uncle got it! I was only calling Makesnow() once… I had some other things wrong with its too… Thanks so much! [import]uid: 95032 topic_id: 16392 reply_id: 61383[/import]

good to hear you got it working
my particle system, graffiti PS, should be ready for release in a couple weeks if you ever find that you need one. I’m hoping to have a web site up in a few days. search on YouTube for jstrahan73 to see videos of graffiti in action [import]uid: 7911 topic_id: 16392 reply_id: 61839[/import]