Forums

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

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #158769
    Ravingdork
    Participant

    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).

    #158774
    Paulie_D
    Member

    Since this relates to JQuery…moved to the Javascript area.

    #158798
    Ravingdork
    Participant

    Ah. Found it again. You scared the crap out of me Paulie!

    Anyone?

    #158804
    __
    Participant

    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');
    
        });
    

    pen

    #158857
    Ravingdork
    Participant

    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?

    #158871
    __
    Participant

    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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.