multi touch controls advice wanted (not joystick..)

old_kipperold_kipper Member Posts: 1,420
edited November -1 in Working with GS (Mac)
HI, want to control 2 atributes from two fingers in 2 areas of the screen, with a third button to fired off other events. I have version working for two fingers by having 2 actors that each have rules for touch one and two (excluding the second touch while outside of the desired actor), but not for a third touch and for ordering the touches so everything still works.

This seems much like the joystick control problem but pushed to add another touch. Is there a template for multitouch that sets up any touch as the master when it is in an area? Or perhaps I just need help/brain transplant/coffee/a good sleep.

Thanks for any help Kipper

Comments

  • old_kipperold_kipper Member Posts: 1,420
    OK.... got it sorted. Was an interesting problem and took a few hours.
  • old_kipperold_kipper Member Posts: 1,420
    no.. no.. I haven't. Found an exemption...
  • JeffreyShimaneJeffreyShimane Member Posts: 372
    Maybe something like this will work...

    Create 3 game attributes (Touch 1, Touch 2, and Touch 3), 1 for each actor, to track whether touch is on or off.

    In Touch 1 actor:
    Rule 1: If touch is pressed,
    - change game attribute Touch 1 from 0 to 1.
    - Rule 2: if Touch 2 and Touch 3 are 0, change self attribute Touch Order to 1
    - Rule 3: if Touch 2 is 1 and Touch 3 is 0, change self attribute Touch Order to 2
    - Rule 4: if Touch 2 is 0 and Touch 3 is 1, change self attribute Touch Order to 2
    - Rule 5: if Touch 2 and Touch 3 are 1, change self attribute Touch Order to 3
    Otherwise:
    - change game attribute Touch 1 to 0
    - change self attribute Touch Order to 0

    Set each button up like that. If you need to access the Touch Order outside the individual actor, then you'll probably need to create 3 game attributes (Touch Order 1, Touch Order 2, and Touch Order 3), one for each actor, that track the order the button was touched in.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I would recommend studying the joystick demo and modifying it. Here's the basic logic - You can't constrain to touch1 or touch2 or whatever because you have no way of knowing the order in which the player will touch the buttons. So you create a tiny actor to constrain to each touch. Then in whatever you want to be able to drag around (constrain) you first check which tiny actor is overlapping with your draggable visible actor. Now you know which touch to constrain it to (based on which tiny actor it is overlapping with). I have used this method for a multitouch game on the ipad that had 8 different actors that needed to have the possibility of all being dragged around at the same time. Modifying the joystick demo worked great.
  • okimokiokimoki Member Posts: 159
    Is there a video tut on how to setup a joystick?? I have hard time figuring that out from the demo and I also need it.. Videos are sooo much more informative since you can see how it's done instead of reverse enginering some template :)
  • old_kipperold_kipper Member Posts: 1,420
    Thanks! This has been 10 hours of sweating and your words bring a real smile at the knowledge there is a way. I will try to work my through a fix based on a deconstructed joystick demo. One question that strikes me immediately- Do you have to return the constrained mini actors to a neutral point when not touched to avoid them being left on any of the areas you want to use for control?

    I had tried to monitor touches within regions with a select for the first until it was false, by leaving the region, and putting timers in to check position of each touch to see if it was the one I wanted to use... It was getting maddening.

    I did have a conversation with a friend who does coding in a mix of open frame works and objective c plus another I can't tool remember and he said that the ios devices do return a event set for each touch, with an release within the event stream for that touch so at that level it can be done. Perhaps in the big version 1 of GS? There was one post I saw from one of the GS chef that mentioned the complexity of setting it up (if I read it correctly...guess I didn't understand what was being said as I just assumed it was in here somewhere ).

    SO thanks again Kipper
Sign In or Register to comment.