3 Replies Latest reply on Nov 1, 2010 5:24 AM by Ned Murphy

    Help with checking things


      Hi, I am making a game for my school project. My game has different levels and a boss level. It is just a choice game where users can choose from option but only one is correct. I was wondering:

      • Is there a way to save the click (if the user click on the right option for enemy one it stores that the player has killed enemy one)
      • If that is possible is there a way to check that information (when the user clicks on the boss room it checks if the enemies have been killed, if so goto that frame, if not display a message saying kill the enemies first)



        • 1. Re: Help with checking things
          Ned Murphy Adobe Community Professional & MVP

          Yes, doing what you want should not be very difficult, but implementing it will depend on the details of your design.  So the best I can offer at the moment is a concept that you should be able to incorporate.


          You could have any array that you use to store each enemy instance, and when an enemy is determined to be killed, you can assign it a value for that, such as ....


          enemy1.killed = true.


          Then, later on when you are checking the statuses, you go thru that array of enemies and test each of their killed values.  As soon as one comes up with a killed value of false, then you know they are not all killed yet.

          1 person found this helpful
          • 2. Re: Help with checking things
            Matt45365 Level 1

            Thanks, so if I am correct, I just click on the button, press f9 and put in something like enemy1.killed = true


            When the player gets to the boss door and clicks on it what code am I supposed to use to check if enemy1.killed = true?


            Sorry if I sound stupid this is my first ever time using flash.



            • 3. Re: Help with checking things
              Ned Murphy Adobe Community Professional & MVP

              Have an array of the enemies...  var enemies:Array; and use that to store all the enemies.


              Each time a new enemy is created, or of they all exist at the start, add each enemy to the array and assign each a property of killed = false to start off.


              When an enemy is killed you change that value to killed = true;


              When you click the door, you go thru the array to see if it is okay to pass thru...



              var okayToPass = true;  // assume it's okay to pass to start


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

                   if(!enemies[i].killed){  // if the current enemy is not killed

                        okayToPass = false;

                        // provide message regarding all enemies not killed yet

                        break; // stop checking