Touch Actor A but Not Actor B behind it...

cotigchezcotigchez Member, PRO Posts: 6
edited November -1 in Working with GS (Mac)
I was wondering if there is a way to keep touch constrained to the Actor that was first touched. I have actors that can be dragged around, sometimes overlapping other actors. The problem is that when one of these actors is overlapping another actor (both which can be dragged around) and is touched, both actors essentially stick to each other, then, indefinitely or until scene is reset. Can I design actors to not be able to be touched-through?

Comments

  • old_kipperold_kipper Member Posts: 1,420
    I think it is basically the same concept as having buttons that can't be pressed at the same time. So you need to make game attributes that say if each is being touched and if only one is touched then it can be picked up. If both are directly in line with each other then you will have to give priority to one over the other. It will be a touch inside to drag and a change of game attribute based on that actor being 'active' and the other not (use a touch release to reset the rule or possibly a timer to check), but if you want to do the priority you will have to make a rule for that as well.

    I am not sure without working out for myself but it should be possible (I think)...

    Hope that helps. kipper
  • simo103simo103 Member, PRO Posts: 1,331
    open GS and in the NEW+ area search 'top card' ... double click it to open .. I think it is a great template of what you are looking to do.
  • MotherHooseMotherHoose Member Posts: 2,456
    okay... I had this with 25 drag-able actors in Einstein's Riddle...

    simply create an Index Attribute in Game set to 0

    assign an index number to your characters... in your case 1 or 2

    on each actor
    Rule when touch is pressed
    --changeAttribute to correct index #
    --and Rule when IndexAttribute = that #
    ----ConstrainAttribute --self.Position.X To: touch1.Position.X
    ----ConstrainAttribute --self.Position.Y To: touch1.Position.Y
    Rule when touch is released changeAttribute index To: 0

    this should also make only the top actor selectable...
    (I also placed actors on different (new) layers to control display in front of behind other actors....)

    MH
Sign In or Register to comment.