Drag and Drop question

SxarcisiousSxarcisious Member Posts: 45
edited December 2011 in Working with GS (Mac)
K so I have an actor on my screen that acts as an 'equip' slot. Then I have an another actor on the screen that when I drag it onto the equip slot it constrains the equip slot XY coords and moves with it. While this actor is colliding with the equip slot it raises certain traits of my main actor.

The problem I am having is... I need to figure out a way so that I can not drag 2 actors onto that equip slot.. Like if an apple is on the equip slot already I can not put another apple on it.(I do not want it to constrain the 2nd actor to the equips XY coords) Unless there is nothing on the equip slot.

I have been trying to figure out the logic in this, and I thought it would not be so difficult, but everything I have tried dosn't work, I just cant seem to get the right rules/logic down for this.

I hope that makes since,
thank you.

Comments

  • delorianhayzedelorianhayze Member Posts: 55
    I am by no means a pro at GS and I'm quite sure there are better suggestions than mine, but in the meantime, how about trying this...
    Create a boolean attribute. We'll call it "Inventory On/Off"
    On start of game have the "Inventory On/Off" set to OFF (or FALSE in boolean terms). This means the inventory slot is vacant.
    Now when the user attempts to put something in that slot-, say something like, IF boolean "Inventory On/Off" is FALSE AND user places object on slot, than place object on slot AND set boolean "Inventory On/Off" to TRUE.. (this means it's okay to put something in the slot as long as there's nothing there).
    Now in this example we have something in the slot.
    If the user attempts to place another object, it would look like this.
    IF user places object on slot and boolean "inventory on/off" is TRUE, do not place object.
    IF user places object on slot and boolean "inventory on/off" is FALSE than place object on slot.

    Does that make sense? Let me know if it doesn't.
  • delorianhayzedelorianhayze Member Posts: 55
    Another possible way to do this is to use "overlap" or "collide" behaviors.
    Here's an example. In our slot we have an APPLE actor. The user attempts to place an ORANGE actor over the APPLE icon.
    Basic coding:
    IF ORANGE overlaps/colides with APPLE, destroy ORANGE. (or bounce, or change position, etc. whatever you want to happen to the orange when the slot is not vacant)
  • SxarcisiousSxarcisious Member Posts: 45
    Thanks, ill give it a shot and will let ya know how it works out.
Sign In or Register to comment.