Touch registering on both overlapping actors
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?
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
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
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)
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.
Off the top of my head I think I used a .25 delay before any action was triggered.