dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Sprinkler animation

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    494

    Sprinkler animation

    I want to have a sprinkler spray water out of it from left to right. Anyone done this or know of a website that has?

    Thanks

  2. #2
    specifically, I do not know of a website that has done it, and I sure havent tried. Your quesiton is a little broad and general. I'm not sure exactly what to tell you. But I can't just make something for you. I would try and learn a little more about MovieClips, and attaching MovieClips with actionscript. This might give you a better idea of what you want to accomplish other than "make a sprinkler"... If you want my advice. Try and make a MovieClip that attaches another MC of water over and over. Then try and make it spurt from that MC into different directions with different _x and _y speeds. It would take a little trying it out to get it right. But learn a little more to try and understand what you are creating before creating it.

    Hope I could help!

    ~Bill
    So many Ideas

    So little Time

  3. #3
    Senior Member
    Join Date
    Feb 2004
    Posts
    494
    I have looked online and I have tried some idea samples with know luck so far.

  4. #4
    Senior Member
    Join Date
    Jun 2003
    Location
    Kent, WA
    Posts
    536
    You'll want to use a particle system that follows the rules of gravity and possibly wind, if you want. It'd look something like this...

    Draw a water drop and make it a movieclip. Have it set to "Export for Actionscript" with the linkage name "water".

    Code:
    density = 2;
    gravity = 1;
    wind = 2;
    createEmptyMovieClip("sprinkler", 0);
    sprinkler.depth = 0;
    sprinkler.onEnterFrame = function() {
       for (var i=0; i<density; i++) {
          var clip = this.attachMovie("water", "water"+this.depth, this.depth++);
          clip._x = Stage.width/2; // x origin for water
          clip._y = Stage.height-100; // y origin for water
          clip.xspeed = Math.random()*6-3; // initial velocity horizontal
          clip.yspeed = -Math.random()*15; // initial velocity upwards
          clip.onEnterFrame = function() {
             this._x += this.xspeed;
             this._y += this.yspeed;
             this.xspeed += wind;
             this.yspeed += gravity;
             if (this._x < 0 || this._x > Stage.width || this._y > Stage.height-100) {
                removeMovieClip(this);
             }
          };
       }
    };
    This should spray water drops everywhere. I haven't tested it so let me know if it doesn't work.

    If you want the drops to fluctuate (directed spray at an oscillating angle), I would use a sine wave. Lemme know if you need help with that.

  5. #5
    Senior Member
    Join Date
    Feb 2004
    Posts
    494
    Ok I have tried this and not working, Maybe it is me not sure.

  6. #6
    Senior Member
    Join Date
    Feb 2004
    Posts
    494
    I got it now. I need it to come from the center of the back and fall down and go from left to right and then slide back fast to the left again and repeat. Ideas on this? I am trying to make a sprikler but not sure how to make it move with the spray and add the noise also.
    Last edited by tim_ver; 06-28-2006 at 12:23 AM.

  7. #7
    Senior Member
    Join Date
    Oct 2001
    Location
    Belgium
    Posts
    467
    -- OOps --

    Sorry, replied by accident when reading this topic.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center