How Do I Solve This?

live_2_winlive_2_win Member Posts: 10
edited November -1 in Working with GS (Mac)
I'm following this tutorial:
The problem is that I have multiple things that I want to drag around, but when two actors overlap each other, and I try to drag one, they both move. Instead of this happening I'd love for it to only drag the one infront.
How could I go about doing that? Thanks in advance.

Comments

  • ApplaudAppsApplaudApps Member Posts: 308
    I had to solve this for my current game. I'll check what I did and post here later (if no one else answers meanwhile)
  • ApplaudAppsApplaudApps Member Posts: 308
    OK, here's what I did :

    Have a game attribute called dragThis, set it to 0 (zero)

    Each actor has an actor attribute called dragID

    You will need a separate actor for each draggable object rather than multiple copies of one actor.

    Give each actor a unique id for dragID (e.g. 1, 2, 3 etc)

    In each actor inside the touch rule have another rule :

    if game.dragThis=0 then game.dragThis=self.dragID (this sets the game attribute to the current draggable object)

    In the 'otherwise' for the touch rule (not the new rule above) have this rule :

    if game.dragThis = self.dragID then game.dragThis = 0 (this frees up the dragThis attribute and means another object can be picked up)

    That finishes the touch rule.

    Then in a completely separate rule do this :

    if game.dragThis = self.dragID then do stuff like move it around etc....

    This works!! I hope you get on ok with it. Basically you set and unset the one object you can move within the 'touch' rule (or mouse click) rule and then have the stuff you can with the actor inside the second rule when it is the currently selected object. Just make sure each actor has a unique dragID

    Good luck!
Sign In or Register to comment.