How to recognize a "touch is not on any of these x number of actors"?

frankwashburnfrankwashburn Member Posts: 32
edited April 2012 in Working with GS (Mac)
Hi all -
Say I have multiple identical actors in a scene.

How can I get them to react to a touch event that does NOT touch ANY of them? I.e. A rogue touch.

"Touch is outside" doesn't work, because if I touch Actor 1, then that's "touch is inside" for him, but "touch is outside" for any other actors in the scene.

Best Answers

  • mynameisacemynameisace Hull, UKPosts: 2,484
    edited April 2012 Accepted Answer
    Made this for you buddy:

    http://mynameisace.com/files/RogueSquadrenLeader.gameproj.zip

    Touch 4 of the actors and then the last one will fall.

    Ace
  • tatiangtatiang Posts: 11,949
    edited April 2012 Accepted Answer
    @frankwashburn Yes, mouse is down means that a touch registered anywhere on the screen. And I thought that the overlapping change attributes (true & false) would be a problem, but in my demo it worked great (http://dl.dropbox.com/u/19602014/Detect Rogue Touch.zip). My other solution was to add a counter to each actor as follows:

    When touch is pressed, change game.counter to game.counter+1; otherwise change game.counter to game.counter-1.

    In the checking actor, check to see if game.counter>0 (a rogue is being pressed!).

    Haven't checked my other solution though... let me know if it works for you.

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    Add a game.actorsTouched boolean attribute set to false. On each actor, add a rule When touch is pressed, change game.actorsTouched to true; otherwise change game.actorsTouched to false.

    Then have a separate actor that checks to see if mouse is down AND game.actorsTouched is false, which would be a rogue touch.

    If you need a demo, let me know.
  • frankwashburnfrankwashburn Member Posts: 32
    @tatiang Is "mouse is down" the same thing as "touch anywhere on the screen?" if I am testing on an iOS device?
  • frankwashburnfrankwashburn Member Posts: 32
    edited April 2012
    @tatiang, Also, if I have three identical actors, each with the rule "When touch is pressed, set game.actorsTouched = true, otherwise set game.actorsTouched to false"... then if I touch just one of the actors, then in the scene there will be one command setting game.actorsTouched to true and 2 that are simultaneously trying to set game.actorsTouched to false, right? Won't that falsely register as a rogue touch then, if I touch any of the proper actors?
Sign In or Register to comment.