Limit touch to a single actor/instance.

tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
I spent way too much time figuring this out, but if it benefits someone else, it's worth it.

There may be a simpler way (oh please, oh please) but I couldn't get this to work with booleans, index counting, or game.Touches.Count. It _almost_ works without resorting to what I did, but not quite.

This -- I think -- ensures that only one answer is chosen, even if multiple actors are tapped.

The key is that each actor (or instance of an actor) must have a unique attribute. In this case, I used self.Label and then populated each instance with a value: A, B, or C. This is to simulate a quiz app.

Comments

  • RazzabandRazzaband Member Posts: 2
    Exactly what is the issue you have encountered?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited January 2013
    It's the same method for routing table rows to a specific actor. I Have a demo of how I did a multiple choice test using tables and always random shuffling the order yet tracking the correct answer. Will send it to you if you like?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @Razzaband The obvious way to limit the number of touches is by doing When touch is pressed and game.Touches.Count=1 ... [action]

    The problem (and in this case, it's a quiz game with a single right answer from multiple choices) is that if you press and hold on two or more actors with that rule and then let go, one or more of the actors triggers that rule and checks for a right answer. So it's very easy to cheat without knowing the correct answer.

    @FryingBaconStudios Yes, it'd be helpful to see another approach, even if it's similar. Thanks!
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    @tatiang will PM with a link to file.
Sign In or Register to comment.