Is there a "Touch moves outside of actor" condition for rules?

For rules for touch-based stuff on Actors, there is:
"Pressed" - touch does not exist, and then suddenly exists on the actor
"Released" - touch exists on the actor, and then does not exist at all
"inside" - any touch anywhere inside the actor
"Outside" - any touch anywhere outside the actor
I need a variant on 'released'... I need my actor to change its behavior if you are touching it, and your touch moves off of it.
I.e. "Touch exists on the actor, and then still exists, but has moved off of the actor"
The problem is, is there are multiple actors at once like this, meaning that "Outside" does not work. If I touch one of my actors, and then simultaneously touch another actor, that secondary touch reads as an "outside" touch and changes the behavior of my first actor.
I want my actor, from being touched to
1) Change behavior if touch is lifted (i.e. "released")
2) Change behavior if the touch that has begun on the actor moves off of the actor's position.
This is proving to be extraordinarily difficult. Any help appreciated.
"Pressed" - touch does not exist, and then suddenly exists on the actor
"Released" - touch exists on the actor, and then does not exist at all
"inside" - any touch anywhere inside the actor
"Outside" - any touch anywhere outside the actor
I need a variant on 'released'... I need my actor to change its behavior if you are touching it, and your touch moves off of it.
I.e. "Touch exists on the actor, and then still exists, but has moved off of the actor"
The problem is, is there are multiple actors at once like this, meaning that "Outside" does not work. If I touch one of my actors, and then simultaneously touch another actor, that secondary touch reads as an "outside" touch and changes the behavior of my first actor.
I want my actor, from being touched to
1) Change behavior if touch is lifted (i.e. "released")
2) Change behavior if the touch that has begun on the actor moves off of the actor's position.
This is proving to be extraordinarily difficult. Any help appreciated.
Best Answer
-
JohnPapiomitis Posts: 6,256
Youll have to make another attribute thats true when the mouse position is inside the actors, and false when its not. Then add when that attribute is false to the conditions of the rule for the touch outside. That way touching another actor doesnt trigger it. I made you a quick demo real quick, let me know if its what your after.
http://www.mediafire.com/?lrdrxvakxf296yj
cheers
Answers
Make a self attribute called touched(boolean)
Have a rule when touch is pressed
-change attribute touched to true
Then have another rule when touch is outside and attribute touched=true
-do whatever
How can:
Rule: Actor receives event Touched is outside && Actor receives event Touched pressed
ever return true? Isn't by definition the touch input being outside of the actor mean that the actor itself is NOT touch-pressed?
Is there a way to give touch events variable names and keep track of them? The challenge is doing this with multiple of these Actors - a touch event outside one of these actors sets off the rules for all of them.
I'd also add a timer and rule to after 1 second of being outside, change the attribute back to false, and another to make it false if you unpress the button just by letting go.
I don't know if that makes any sense. If not, just say so, and I'll try to clear it up.
Asymptoteell
What i said will correct that, because youll have to touch it first then move the touch off of it for it to trigger, and it wont effect every actor. Only the one the action was applied to. Try it out.
Nevermind, I think I figured it out:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang - Shouldn't the second rule be "Actor receives event touch is OUTSIDE" rather than Released?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
when they have that rule
try this:
add an actor and the
Rule: when
Event: touch is outside
--changeAttribute: self.Color.Alpha To: 0.2
Otherwise:
--changeAttribute: self.Color.Alpha To: 1
drag a few of these actors to the scene
Preview and touch (and hold down the mouseButton) outside the actors
they all change their Alpha
release and they all change
the whole displayArea of the device is touch sensitive and tracks the position of a touch
actors receive the events:
touch: pressed; inside; outside;
however, an actor receives the event 'released' only when touch is inside that actor
we do not have to track the the touch pressed or released position … the computer does that!
small demo: http://www.mediafire.com/?cxuidbj5jn5no1i
I have two identical Actors with your suggested implementation in the scene.
I touch one - so it changes state, and Actor1.istouched turns to TRUE.
Then I touch the second Actor - Actor1 immediately receives a "touch received OUTSIDE" and changes again!!
Simply trying to touch multiple of these Actors at once counts as a "touch received OUTSIDE actor" and thus disables all of the other actors.
One last thing though - I think there's one more rule that I need. A rouge touch that doesn't land on any of the Actors at all should disable all of them - by changing game.onAnotherActor to false.
Because there needs to be a rule to SET game.onAnotherActor to FALSE, otherwise once it gets changed to TRUE it will never be set back to FALSE.
How does one implement a rule like that?
Is it possible to layer Actors? Maybe I could make the background art of the scene an Actor, and if any touch touches it and not the Actor in front of it, then it sets game.onAnotherActor to FALSE.
I am keeping a counter on all Actors that are being touched.
If I do:
Rule:
If Actor receives touch that is outside
&&
Counter does NOT change
Then deactivate.
Is checking to see whether a counter changes upon the device receiving a touch is as simple as
"Attribute counter =/= counter"?