2 Replies Latest reply on Mar 1, 2007 7:41 PM by kglad

    gotoandPlay

    betrot
      Hi,
      I have a game where a paddle (instance name: paddle) is hitting a ball (instance name: ball) which drops from the top of the screen. There is a dynamic text box (variable: score) which adds 5 each time the paddle hits the ball. This all works.

      However, the if statement to send the movie to the next scene ("Game_2 Congratz) when score is greater than 20 will not work. A trace will work.

      The actionscript is as follows:

      //to start dragging the paddle on the mouse
      onClipEvent (enterFrame) {
      startDrag(this, true, 0, 300, Stage.width, 300);

      //to start the ball falling from the top of the screen
      this._parent.ball._y = this._parent.ball._y+17;

      //to send the ball back to the top of the screen if the paddle misses it
      if (this._parent.ball._y>400) {
      this._parent.ball._y = 0;
      this._parent._x = random(400);

      //to take one point from the score if the paddle misses the ball
      this._parent.score -= 1;
      }

      //to send the ball back to the top of the screen if the paddle hits it
      if (this._parent.ball.hitTest(this)) {
      this._parent.ball._y = 0;
      this._parent.ball._x = random(400);

      //to add five points to the scroe if the paddle hits it
      _root.score = _root.score+5;
      }

      //to go to the next scene if the score is greater than 20 (with a trace)
      if (_root.score>20) {
      trace("hit");
      gotoAndPlay("Game_2 Congratz", 1);
      }
      }

        • 1. Re: gotoandPlay
          XillX
          quote:

          Originally posted by: betrot
          Hi,
          I have a game where a paddle (instance name: paddle) is hitting a ball (instance name: ball) which drops from the top of the screen. There is a dynamic text box (variable: score) which adds 5 each time the paddle hits the ball. This all works.

          However, the if statement to send the movie to the next scene ("Game_2 Congratz) when score is greater than 20 will not work. A trace will work.

          The actionscript is as follows:

          //to start dragging the paddle on the mouse
          onClipEvent (enterFrame) {
          startDrag(this, true, 0, 300, Stage.width, 300);

          //to start the ball falling from the top of the screen
          this._parent.ball._y = this._parent.ball._y+17;

          //to send the ball back to the top of the screen if the paddle misses it
          if (this._parent.ball._y>400) {
          this._parent.ball._y = 0;
          this._parent._x = random(400);

          //to take one point from the score if the paddle misses the ball
          this._parent.score -= 1;
          }

          //to send the ball back to the top of the screen if the paddle hits it
          if (this._parent.ball.hitTest(this)) {
          this._parent.ball._y = 0;
          this._parent.ball._x = random(400);

          //to add five points to the scroe if the paddle hits it
          _root.score = _root.score+5;
          }

          //to go to the next scene if the score is greater than 20 (with a trace)
          if (_root.score>20) {
          trace("hit");
          gotoAndPlay("Game_2 Congratz", 1);
          }
          }




          in stead of "gotoAndPlay("Game_2 Congratz", 1);" try something like "gotoAndPlay("frame")or("scenenumber","frame")" depending if it is in the same scene.
          • 2. Re: gotoandPlay
            kglad Adobe Community Professional & MVP
            don't use scene information for navigation and don't use the goto functions. use frame labels and the goto methods: