3 Replies Latest reply on Sep 9, 2010 10:42 PM by kglad

    No result with this code

    0slimjimmy0 Level 1

      The problem is that it won't add 100 to the score.

       

      File: http://www.mediafire.com/?3o7qo4w1ou4j5cd

       

      Code for frame 1(Menu):
      stop();
      Score = 0;

      Code for frame 2(Level):
      stop();
      Score = Score;
      Points.text = "Score: " + Score;//"Points" is the instance name of the Score text box which is Dynamic Text. "Score" is the variable for the text box.

      Code for coins:
      onClipEvent (enterFrame) {
      if (this.hitTest(_root.player))
      {
        unloadMovie(this);
        score += 100
      }
      }
      Code for player:
      onClipEvent (load) {
      speed = 5;
      gravity = 0;
      jumpSpeed = 5;
      jumping = false;
      gravityAcc = 0.3;
      }
      onClipEvent (enterFrame) {
      if (Key.isDown(Key.RIGHT))
      {
        this._x += speed;
        this.gotoAndStop(1);
      }
      if (Key.isDown(Key.LEFT))
      {
        this._x -= speed;
        this.gotoAndStop(2);
      }
      if (Key.isDown(Key.UP))
      {
        jumping = true;
      }
      if (jumping)
      {
        this._y -= jumpSpeed;
      }
      gravity += gravityAcc;
      this._y += gravity;
      if (this.hitTest(_root.ground))
      {
        this._y -= gravity;
        gravity = 0;
        jumping = false;
      }
      if (this.hitTest(_root.coin))
      {
        Score += 100;
      }
      }

        • 1. Re: No result with this code
          kglad Adobe Community Professional & MVP

          try:

           


           

          Code for frame 1(Menu):
          stop();
          Score = 0;

          Code for frame 2(Level):
          stop();
          Score = Score;
          Points.text = "Score: " + Score;//"Points" is the instance name of the Score text box which is Dynamic Text. "Score" is the variable for the text box.

          Code for coins:
          onClipEvent (enterFrame) {
          if (this.hitTest(_root.player))
          {
            unloadMovie(this);
            _parent.Score += 100
          }
          }
          Code for player:
          onClipEvent (load) {
          speed = 5;
          gravity = 0;
          jumpSpeed = 5;
          jumping = false;
          gravityAcc = 0.3;
          }
          onClipEvent (enterFrame) {
          if (Key.isDown(Key.RIGHT))
          {
            this._x += speed;
            this.gotoAndStop(1);
          }
          if (Key.isDown(Key.LEFT))
          {
            this._x -= speed;
            this.gotoAndStop(2);
          }
          if (Key.isDown(Key.UP))
          {
            jumping = true;
          }
          if (jumping)
          {
            this._y -= jumpSpeed;
          }
          gravity += gravityAcc;
          this._y += gravity;
          if (this.hitTest(_root.ground))
          {
            this._y -= gravity;
            gravity = 0;
            jumping = false;
          }
          if (this.hitTest(_root.coin))
          {
            _parent.Score += 100;
          }
          }

          • 2. Re: No result with this code
            0slimjimmy0 Level 1

            Thanks for your help

            • 3. Re: No result with this code
              kglad Adobe Community Professional & MVP

              you're welcome.