3 Replies Latest reply on May 16, 2008 2:45 AM by andyulrika_is_back

    True or False Quiz

    andyulrika_is_back
      Hello

      I have written a 'rough' behaviour which I attach to 2 sprites named True and False. When the 'correct' sprite is clicked on the 'wrong' sprite blend displays 20% and vice versa. Both sprites when clicked on also change members to either a tick or cross depending on their settings.

      It's pretty rough because I'm still learning lingo - But I'm trying to achieve the following...

      After the choice has been made there can be no further interaction on both of the sprites (without changing frames or navigating to a another marker). Something which kills the code in someway.

      What is happening now is that I can select an answer and the other sprites blend turns to 20% - That's fine. But, if I click on the sprite that has a blend of 20% then it makes the original selected sprite turn to 20%. Basically, I want to make the blended sprite inactive.

      Any help much appreciated.

      Andy
        • 1. Re: True or False Quiz
          Level 7
          Use a property to store if clicking it is valid:

          > property pSelect, pCorrect, pWrong, pKill

          property pEnabled

          >
          > on mouseUp me

          if pEnabled then

          > if pSelect then

          pEnabled=false

          > sprite(me.spriteNum).member=pCorrect
          > sprite(pCorrect).blend=100
          > sprite(pKill).member=pWrong
          > sprite(pKill).blend=30
          > sound(3).play(member("welldone"))
          > else
          > sprite(me.spriteNum).member=pWrong
          > sprite(pKill).member=pCorrect
          > sprite(pCorrect).blend=100
          > sprite(pKill).blend=30
          > sound(3).play(member("wrongchoice"))
          > end if

          end if
          end mouseUp

          on beginSprite
          pEnabled=true
          end beginSprite


          You don't need to check "if something=true then..." because that's the same
          as "if something then...". But sometimes it does make it more obvious what
          you're doing.

          Also, you didn't need the second "if pSelect=False then..." because if
          pSelect is not true then it /must/ be false.

          HTH

          Andrew


          • 2. Re: True or False Quiz
            Level 7
            Oh, and you'll need to disable the other sprite:

            >> on mouseUp me
            > if pEnabled then
            >> if pSelect then
            > pEnabled=false

            sprite(pKill).pEnabled=false

            <snip>

            Andrew


            • 3. Re: True or False Quiz
              andyulrika_is_back Level 1
              Hi Andrew

              Thanks for the fix. I think I understand the logic of the true / false now. Although I had to read it about 10 times to get the logic into my head!

              Regards

              Andy