2 Replies Latest reply on Jul 4, 2006 2:20 PM by Dilbert_15


      Hey, guys, this shouldn't be too hard a question, but it's one that I can't find the answers to.

      I want to create an inventory for a game I'm making. Basically, I want a variable for each item (in possesion, not in possesion, or lost (will explain later)), and if this variable is flagged as true (or yes, 1, or some other variant) then show this graphic. If not, then it won't appear. I don't know if this is a catch or not, but these things are supposed to be clickable, but only if they are visible.

      Oh, one other catch: One of said inventory items is a backpack of sorts. If this item is ever missing, I want all other items to be flagged as "lost" so that they are technically in possesion, but are not visible and cannot be used.

      How can I do all of this? Thanks in advance for any help you can offer.
        • 1. Variables/conditions
          Eh, I'm not really good at coding the professional way. But I think this should work (I didn't test it).

          itemArray[1] = new Object()
          itemArray[1].item = "banana"
          itemArray[1].mc = _root.bananagraphic
          itemArray[1].have = true
          itemArray[1].lost = false

          so, in that piece, for every item, make a new one with another number (1 higher than the last one). The "mc" is the graphic movieclip. The "have" variable is to say if you got it or not, and same with lost.

          itemArray .mc._visible=itemArray.have
          that one makes all the items that you have visible.

          if(itemArray[0].hitTest(_root._xmouse,_root._ymouse,true) && itemArray[0].have && !itemArray[0].lost)
          (you need one for every number)
          This part (when the mouse is down) checks if the mouse has touched the movieclip, if you have it, and if it's not lost. If it fits it all, then it does something.

          I hope this helps :D!
          • 2. Re: Variables/conditions
            Dilbert_15 Level 1
            Thank you for the reply (I know I'm late in answering, but I forgot to bookmark this place and needed to find it again).

            I'm going to need to read more tutorials on Flash Actionscript, I see. When I understand all this, I'll test it out. :D