Results 1 to 7 of 7

Thread: Snow Falling Without Dissappearing

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Snow Falling Without Dissappearing

    Hi Guys,

    With the attached file I've got some snow falling, I want the snow to build up st the bottom of the file like it would in real life... If anyone has any ideas would be great! Also here is the code if that helps...
    Code:
    snowNumber = 70;
    var flakes:Array = new Array("snow", "flake2", "flake3","flake4") 
    for (i=0; i<snowNumber; i++) {
    	newSnow = _root[flakes[random(flakes.length)]].duplicateMovieClip("snow"+i, i);
    	newSnow._x = Math.random()*Stage.width;
    	newSnow._y = -Math.random()*300;
    	newSnow.maxSnowSpeed = Math.random()*4;
    	newSnow.wind = Math.random()*6;
    	newSnow._xscale = newSnow._yscale = newSnow.alpha = Math.random()*60+40
    	newSnow.onEnterFrame = function() {
    		this._rotation -= this.maxSnowSpeed+1;
    		if(this._y>Stage.height || this._x>Stage.width || this._x<0){
    			this._y = -Math.random()*300;
    			this._x = Math.random()*Stage.width;
    		} else {
    			this._y += this.maxSnowSpeed+1;
    			this._x += this.wind-4;
    		}
    		
    		this._alpha = this.alpha;
    	};
    }

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Since javascript isn't my area, I'll just offer some logic advice:

    You could try to make it stop when it hits the bottom of the page.

    However, that'll just make a line of snowflakes. Making it actually build on top of itself is VERY complex, since you would need to track each and every snowflake as it hits the bottom.... the code isn't setup for that now... and it would be a lot more to add, and might just not work due to memory overload in the browser, though I'm not sure about that.

    I guess the other option is to randomize it... 1 in 10 stops 1/2" from the bottom of the page, etc. That wouldn't be perfect, but might be a little better, though.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Check out This Movie to get the accumulation effect.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Oh, oops. I thought the above was javascript, since the AS and JS look so similar. I think I thought it was the script from DD... nevermind.

    Interesting example.

    I can't tell from your code how large the image representing a snowflake is, but the problem may be that the example uses 1 px flakes which can easily fit together... with oddly shaped flakes, you'd get odd buildup. Either on touch, they'd stop at oddly "balanced" angles to each other, or you'd need to add in some sort of realistic bouncing/rotating on contact. Seems fairly complex.
    Maybe setting it to stop when it hits the center of another flake... when the outside edge of a flake touches the center of another, it should stop... that would look more realistic and get a nice layered effect.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Using hittest is a good option, but again a lot of coding.

    To prevent the oddly shaped build up, he could always leave the code the way it is and make a masked layer with the "buildup" and remove the mask over time.

    Plenty of ideas, depends on the execution.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    Using hittest is a good option, but again a lot of coding.

    To prevent the oddly shaped build up, he could always leave the code the way it is and make a masked layer with the "buildup" and remove the mask over time.

    Plenty of ideas, depends on the execution.
    Hey Blizzard! Hey do you have any idea how I can make the snow on a particular layer... I moved it to the bottom of all the layers but when it falls it still falls on top of all the elements, maybe it's to do with _root?

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Not sure what you mean.. shouldn't the snow be on the top of everything else?

    Anyway, you can set the nextHighestDepth stuff, or keep it on the same depth etc etc... when you make the snow (flake1, flake2, etc) each is being placed on a layer on top of the previous, over time they are going to be in the thousands, and regardless of layer placement in the FLA the swf will continue to build.

    Why I suggested the mask option. With that you can only have say 100 random flakes, and REMOVE each flake as it's _y>=600 or so. Then it will not build up on the depth layers and you still produce the effect that it is "building" a nice little pile.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •