Help with MultiTouch!!!

FlightfreakAppsFlightfreakApps Member Posts: 20
edited November -1 in Working with GS (Mac)
Hello everyone. I have gotten tons of help from you guys in the past and I have another question. I am (trying) to make a Pong-like game in which there are two players, and you use your finger to drag the paddle up and down. But, to be able to drag both at once, do you hove to use MultiTouch, or is it even possible? I have tried using two attributes (paddle1drag and paddle2drag), but to no avail. Thanks for your help.

Comments

  • FlightfreakAppsFlightfreakApps Member Posts: 20
    anyone? no?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    I am not sure where you are starting from -- so lets start from a template!

    Go to the "Basic Table Tennis Template".

    In the red "player 1 paddle" delete (or turn off) the two rules that are labeled "Move Up Rule" and "Move Down Rule". Then add a new constrain behavior:

    Constrain Attribute: self.position.Y To: game.Touches.Touch 1.Y

    You can test it out on the viewer or an ad hoc (but it won't work on the Mac).

    When you get that working, you can then move on to the blue "player 2 paddle". In that one, you would constrain it to: game.Touches.Touch 2.Y

    This should get you started!

    ------------------
    Hmmm.... If you want both paddles to move in unison with one touch then -- you can also constrain the blue paddle to: game.Touches.Touch 1.Y
  • FlightfreakAppsFlightfreakApps Member Posts: 20
    Thanks!
  • lovelostlovelost Member Posts: 7
    In the example, the red paddle is constrained to Touch1 and the blue paddle to Touch2. But what happens if the person playing the blue paddle happens to touch the screen before the person on the red paddle? Doesn't that mean the blue paddle is now getting Touch1 rather than Touch2?

    Is there a way to establish which touch has hit an object, and constrain to that touch at run time, given that in many multi-touch game scenarios you can't predict the order in which touches will hit the screen?
  • COBGamesCOBGames Member Posts: 114
    wouldn't you just have it as touch and not touch1 or touch2? this way it doesn't matter when it is touched, just if it is?
  • GeromeGanGeromeGan Member Posts: 4
    Any guru here can help solve this? I am also getting stuck with this one.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Here is a quick idea (meaning it will still need some work but might get you in the ball park).

    Using the template and instructions from above, wrap the red paddle's constrain attribute in a rule like this:

    When
    ----Attribute: game.Touches.Touch 1.X < 240
    --------Constrain Attribute: self.Position.Y To: game.Touches.Touch 1.Y
    ----Otherwise
    --------Constrain Attribute: self.Position.Y To: game.Touches.Touch 2.Y

    For the blue paddle:

    When
    ----Attribute: game.Touches.Touch 1.X > 241
    --------Constrain Attribute: self.Position.Y To: game.Touches.Touch 1.Y
    ----Otherwise
    --------Constrain Attribute: self.Position.Y To: game.Touches.Touch 2.Y

    Its not perfect, but might give an idea of what to do.

    RThurman
Sign In or Register to comment.