Skip to main content
Known Participant
January 26, 2013
Answered

Attach movie clip speed increase after 2 min

  • January 26, 2013
  • 1 reply
  • 1033 views

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

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

                                                  allBalls.splice(i, 1);

                                        }

                              }

                              this.removeMovieClip();

                    }

           };

}

makeOne();

makeTwo();

makeThree();

makeFour();

makeFive();

makeSix();

makeSeven();

makeEight();

makeNine();

makeTen();

setTimeout(makegd,180000);

This topic has been closed for replies.
Correct answer kglad

:

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.

          }

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 26, 2013

:

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.

          }

Known Participant
January 26, 2013

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

                                                  allBalls.splice(i, 1);

                                        }

                              }

                              this.removeMovieClip();

                    }

           };

}

setTimeout(makegd,180000);


kglad
Community Expert
Community Expert
January 26, 2013

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

                                                  allBalls.splice(i, 1);

                                        }

                              }

                              this.removeMovieClip();

                    }

           };

}

setTimeout(makegd,180000);