7 Replies Latest reply on Jan 28, 2013 7:34 AM by kglad

    Attach movie clip speed increase after 2 min

    mandar vedak Level 1

      i am making a game in falsh as2

       

      see this link to understand http://createview.in/try/game.html

       

      this function for one fruit.

       

      so there are 10 functions i want to increase speed of falling fruits after 2 min for making difficulties to user

       

      makegd is function for bonus golden fruit it will come every 3 min

       

      PLEASE HELP ME!!!!!!!!!!!!!!!!!!!!

       

      function makeOne() {

                if (seconds>0) {

                          clearInterval(ranOneID);

                          ran = (Math.random()*10000+8500);

                          ranOneID = setInterval(makeOne, ran);

                          One = _root.attachMovie('n_red', 'n_red'+depth, depth++);

                          nBalls.push(One);

                          //trace(allBalls);

                          One._x = Math.random()*500;

                          One._y = -350;

                          One.speed = (Math.random()*3)+2;

                }

       

                One.onEnterFrame = function() {

                          this._y += this.speed;

                          if (this._y>Stage.height+100) {

                                    //updateScore(-5);

                                    black=black+1;

                                    for (i=0; i<allBalls.length; i++) {

                                              if (this == allBalls[i]) {

                                                        allBalls.splice(i, 60);

                                              }

                                    }

                                    this.removeMovieClip();

                          }

                          if(this.hitTest(slider_mc.kat)){

       

                          red = red+1;

                }

                };

      }

       

       

      function makegd() {

                if (seconds>0) {

                          clearInterval(rangdID);

                          rangdID = setInterval(makegd, ran);

                          gd = _root.attachMovie('golden', 'golden'+depth, depth++);

                          goldenBalls.push(gd);

                          //trace(allBalls);

                          gd._x = Math.random()*500;

                          gd._y = -100;

                          gd.speed = (Math.random()*8)+3;

                }

                gd.onEnterFrame = function() {

                          this._y += this.speed;

                          if (this._y>Stage.height+100) {

                                    //updateScore(-5);

                                    for (i=0; i<allBalls.length; i++) {

                                              if (this == allBalls[i]) {

                                                        allBalls.splice(i, 1);

                                              }

                                    }

                                    this.removeMovieClip();

                          }

                 };

      }

       

       

       

      makeOne();

      makeTwo();

      makeThree();

      makeFour();

      makeFive();

      makeSix();

      makeSeven();

      makeEight();

      makeNine();

      makeTen();

      setTimeout(makegd,180000);

        • 1. Re: Attach movie clip speed increase after 2 min
          kglad Adobe Community Professional & MVP

          :

           

          var speedVar=2;

          setTimeout(speedF,120000);

          function speedF(){

          speedVar++;  // adjust per your needs

          }

           

          function makeOne() {

                    if (seconds>0) {

                              clearInterval(ranOneID);

                              ran = (Math.random()*10000+8500);

                              ranOneID = setInterval(makeOne, ran);

                              One = _root.attachMovie('n_red', 'n_red'+depth, depth++);

                              nBalls.push(One);

                              //trace(allBalls);

                              One._x = Math.random()*500;

                              One._y = -350;

                              One.speed = (Math.random()*3)+speedVar;  // depending on what you want, you may also want to use a variable instead of 3.

                    }

          • 2. Re: Attach movie clip speed increase after 2 min
            mandar vedak Level 1

            Thank you Kglad for your quick response.

             

            one thing that not happen

             

            makegd is function for bonus golden fruit it will come every 3 min

             

            it comes after 3 min but it's not single fruit that function work like other fruits.

             

            function makegd() {

                      if (seconds>0) {

                                clearInterval(rangdID);

                                rangdID = setInterval(makegd, ran);

                                gd = _root.attachMovie('golden', 'golden'+depth, depth++);

                                goldenBalls.push(gd);

                                //trace(allBalls);

                                gd._x = Math.random()*500;

                                gd._y = -100;

                                gd.speed = (Math.random()*8)+3;

                      }

                      gd.onEnterFrame = function() {

                                this._y += this.speed;

                                if (this._y>Stage.height+100) {

                                          //updateScore(-5);

                                          for (i=0; i<allBalls.length; i++) {

                                                    if (this == allBalls[i]) {

                                                              allBalls.splice(i, 1);

                                                    }

                                          }

                                          this.removeMovieClip();

                                }

                       };

            }

             

            setTimeout(makegd,180000);

             


            • 3. Re: Attach movie clip speed increase after 2 min
              kglad Adobe Community Professional & MVP

              use:

               

              function makegd() {

                        if (seconds>0) {

                                  //clearInterval(rangdID);

                                  //rangdID = setInterval(makegd, ran);

                                  gd = _root.attachMovie('golden', 'golden'+depth, depth++);

                                  goldenBalls.push(gd);

                                  //trace(allBalls);

                                  gd._x = Math.random()*500;

                                  gd._y = -100;

                                  gd.speed = (Math.random()*8)+3;

                        }

                        gd.onEnterFrame = function() {

                                  this._y += this.speed;

                                  if (this._y>Stage.height+100) {

                                            //updateScore(-5);

                                            for (i=0; i<allBalls.length; i++) {

                                                      if (this == allBalls[i]) {

                                                                allBalls.splice(i, 1);

                                                      }

                                            }

                                            this.removeMovieClip();

                                  }

                         };

              }

               

              setTimeout(makegd,180000);

               


              1 person found this helpful
              • 4. Re: Attach movie clip speed increase after 2 min
                mandar vedak Level 1

                Hi Kglad,

                 

                i apply this function in my code but speed is remain same

                 

                how can i trace the speed is increasing 

                • 5. Re: Attach movie clip speed increase after 2 min
                  kglad Adobe Community Professional & MVP

                  copy and paste the code you're using that incorporates the code suggested in both my messages.

                  • 6. Re: Attach movie clip speed increase after 2 min
                    mandar vedak Level 1

                    Sorry my mistake, i put in wrong place

                     

                    But now it's DONE!!!!!!!!!!!!!!

                     

                    Thank you very much for your help