Touch registering on both overlapping actors

BeyondtheTechBeyondtheTech Member Posts: 809
edited November -1 in Working with GS (Mac)
I have two actors. One is a background in the background layer. When I spawn actors from it, I place the new actor "in front of layer."

But, when I add a Touch Rule for both actors, it seems to trigger on both actors.

How can I make the touch work only on the actor in the foreground?

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I'm not sure, but a workaround using attributes is possible:

    create two attributes:
    actor
    background

    On your actor create a rule:
    when actor receives touch
    change game.Actor 1

    when game.Actor = 1
    DO ACTION
    change game.Actor =0 (so it resets itself)

    do the same thing on the background, but add a 2nd rule:
    when actor receives touch
    change game.Background 1

    when game.Background= 1 AND game.Actor = 0
    DO ACTION
    change game.Background=0

    something like that should work. I might put the background action on a timer to make sure the actor's value is changed, like a .1 delay
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    The other work around is to use invisible actor to trigger game attributes. Then you can change the size of the invisible actors without changing what they player actually sees. So instead of a rule in the visible actor that says when touch is pressed do this that and the other thing. Make a boolean game attribute and use that instead. So it would look like

    Rule
    When attribute game.something is true
    do this that and other thing

    Then in the invisible actor have a rule

    when touch is pressed
    change attribute game.something to true(1)

    OTHERWISE

    change game.something to false (0)
  • BeyondtheTechBeyondtheTech Member Posts: 809
    Nothing seems to work consistently, even on a delay.

    It appears that the touch trigger events in both actors could happen in any order, so while the foreground actor may set the Game.ItemTouched=true, the test performed in the background actor may not register it in time, and it will consider a miss.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    when I get home I'll see if I can dig out the code I used in V is for Vortex, I added a new achievements screen where you can click on trophies to view them, and then again to close it. I've got layered 'hot zones' in that field, and after a bunch of trial and error, I got it to work every time.

    Off the top of my head I think I used a .25 delay before any action was triggered.
Sign In or Register to comment.