Touch event kept in memory?

OK... moving this to Forum as suggested by a user.
So I’m running into an issue that I can’t resolve. Maybe someone can help.
1) I created two actors
2) Actor “A” – When you Touch Press this actor, it changes an Attribute called “myPush” from 0 to 5 (I use Display text to show this number)and when you “Touch Release” it, it changes the attribute to 9.
3) Actor B has a similar function. Touch Press changes Attribute called “mySecondPush” from 0 to 15 and Touch Release changes it to 45 (I also use Display Text to show this number)
4) Actor B has a rule though, that it’s only “active” as long as myPush = 9. That means that you have to Touch and Release Actor A, before Actor B does anything.
Everything works fine if I first press Actor “A” then Actor “B”… Actor “A” shows 5 then 9 (as I release), and Actor “B” now shows 15 then 45 when I release…..
NOW HERE IS MY ISSUE:
If I first press Actor B, nothing happens (as it should). But when I
then press Actor A, the text on Actor B suddenly changes to “45”??? It’s as if the game is storing the touch event and waiting to execute when the “A” rule is met.
That doesn’t seem right to me. The touch event should not be held in memory, and if it is, then how do I clear it?
So I’m running into an issue that I can’t resolve. Maybe someone can help.
1) I created two actors
2) Actor “A” – When you Touch Press this actor, it changes an Attribute called “myPush” from 0 to 5 (I use Display text to show this number)and when you “Touch Release” it, it changes the attribute to 9.
3) Actor B has a similar function. Touch Press changes Attribute called “mySecondPush” from 0 to 15 and Touch Release changes it to 45 (I also use Display Text to show this number)
4) Actor B has a rule though, that it’s only “active” as long as myPush = 9. That means that you have to Touch and Release Actor A, before Actor B does anything.
Everything works fine if I first press Actor “A” then Actor “B”… Actor “A” shows 5 then 9 (as I release), and Actor “B” now shows 15 then 45 when I release…..
NOW HERE IS MY ISSUE:
If I first press Actor B, nothing happens (as it should). But when I
then press Actor A, the text on Actor B suddenly changes to “45”??? It’s as if the game is storing the touch event and waiting to execute when the “A” rule is met.
That doesn’t seem right to me. The touch event should not be held in memory, and if it is, then how do I clear it?
Comments
Use the 'released' touch command and set up a boolean attribute for when each actor is pressed, so 'actorApressed' and 'actorBpressed'.
Make the corresponding actors turn that attribute to true when they are released and false otherwise. Then tell the actors that when the opposing attribute is true to destroy itself.
So in actorA:
`When touch is released - change attribute game.actorApressed = true, Otherwise game.actorApressed = false`
&
`When game.actorBpressed = true - destroy self.`
And vice versa.
Now when you press one, the other will cease to exist.
Then add a command so after 0.1 seconds the actor you just released re-spawns the actor that just deleted itself.
This seems to wipe any commands kept in memory and has worked well for me.