- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Trying to make snow fall down
I’m trying to get Starry Night to fall downwards, like snow.
How do I do that? Fiddling around with the jquery, I’ve managed to get it to fly up, but not down.
(Sorry if this post is redundant, my previous one seems to have disappeared).
Since this relates to JQuery…moved to the Javascript area.
Ah. Found it again. You scared the crap out of me Paulie!
Anyone?
Just change the backgroundPosition
values in each function call. Make the first value (x) smaller; make the second value (y) much larger (and positive; otherwise your snow will fall up).
$(function(){
$('#midground').css({backgroundPosition: '0px 0px'});
$('#foreground').css({backgroundPosition: '0px 0px'});
$('#background').css({backgroundPosition: '0px 0px'});
$('#midground').animate({
backgroundPosition:"(-1000px 10000px)"
}, 240000, 'linear');
$('#foreground').animate({
backgroundPosition:"(-1000px 10000px)"
}, 120000, 'linear');
$('#background').animate({
backgroundPosition:"(-1000px 10000px)"
}, 480000, 'linear');
});
Thanks! That did the trick.
I’ve also noticed that the snow freezes in place after a time. Is there a way to keep it falling in perpetuity?
No idea; I didn’t actually look at how it works. Since they’re just background images, I would assume you simply reached the bottom. You’d have to “reset” the position, somehow.