5 Replies Latest reply on Jul 18, 2009 10:46 AM by Ned Murphy

    Score For My Game

    LPeekaman

      Is there an actionscript for a point system? I want my points to be time based from this script

       

      stop();
      count = 60;
      countdown = function(){
      count--;
      if (count ==0){
      clearInterval(doCountdown);
      gotoAndStop(11);
      clearInterval(doCountdown);}
      }

      doCountdown = setInterval(countdown, 1000);
      Help?

        • 1. Re: Score For My Game
          Ned Murphy Adobe Community Professional & MVP

          There is no actionscript specifically for a point system.  You will have to think of your own scheme for determining points.  If it is time based, then you have the count value that is representing the number of seconds remaining.  So figure out what you want to base the score on using that value if time is part of it.

          • 2. Re: Score For My Game
            LPeekaman Level 1


            Maybe time multiply by 8? I figured the variable is count but how do i use it.

            • 3. Re: Score For My Game
              Ned Murphy Adobe Community Professional & MVP

              You use it whatever way you decide you to.  The time played is different from the count in that the time played would be 60 - count.  So if you want to make the score 8 times the time played you just use

               

              var finalScore = 8 * (60 - count);

               

              You should review the help documentation for the operators that Flash uses so that you will understand how to perform basic math in code.

              1 person found this helpful
              • 4. Re: Score For My Game
                LPeekaman Level 1

                When I do that it just says NaN. I don't know if i did it right, I created a new layer, I changed the textbox variable to finalScore, and added the script you gave me but it jsut appears as NaN.

                 

                 

                Do I put it on the countdown time's layer or a seperate layer with a textfield

                • 5. Re: Score For My Game
                  Ned Murphy Adobe Community Professional & MVP

                  Don't use the variable feature of the textfield.  Assign the textfield an instance name (let's say you name it scoreText), and when you are ready to add text to it use

                   

                  scoreText.text = 8 * (60 - count);

                   

                  If you are still getting NaN, that probably means your count variable is no longer in scope for where you are on the timeline.  So the easiest way to manage this for you would probably be to use count as a _global variable, meaning, everywhere you use count, you instead use _global.count.  Another way would be to have a layer dedicated to shared data that extends the entire length of the timeline, and in that layer you could declare:

                   

                  var count;

                   

                  That way, count will be avaiable to anything along the timeline.

                  1 person found this helpful