Touch one or Touch two Question

ElfizmElfizm Member Posts: 489
edited October 2012 in Working with GS (Mac)
Hello

So quick question that I need help with. If I have a two player on screen game where it involves players to always touch their bat ect. Can I just say if touched do action, or do I have to say if touch one or touch two. There is going to be two touch points on the screen. So only if player one is being touched will it move to touch position. But there is also player two actor that only moves when touch and follows touch position. How would I do this.

Bit confused in how i am going to know who is touch one ect.


Thanks
Elfizm

Comments

  • ElfizmElfizm Member Posts: 489
    Some more questions if anyone can help.

    In regards to previous question, if two touches are at the same time. And one touch becomes released. Will the other one be recongised as touch one or will it stay at touch two.

    Elfizm
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Once a touch is given a touch count by the software it will keep that touch assignment until it is released.
  • ElfizmElfizm Member Posts: 489
    @FryingBaconStudios

    Thanks heaps, so how would each actor know which touch position to follow if it can keep Changing touch count?. A two player pong type game for example?

    Elfizm
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited October 2012
    Okay so here is a quick explanation of multi touch. The touch count only indicates how many fingers are on the screen, so if you had no actors on the screen and touched it with two fingers the touch count would be 2. So there is minimal relation between when an actor is touched and the touch count. In an actor rule touch is pressed means the screen is being touched inside the area of the screen the actor occupies.
  • ElfizmElfizm Member Posts: 489
    Great thanks @FryingBaconStudios

    So just to confirm things, the two actors, player one and player two. If they are pressed and the touch is moved they will move to that touch position. But what if both actors are touched at same time with two different fingers, will it know only to follow the touch position of the one that touched it or will it go straight to the other actors touch position.

    Does that makes sense? And thanks again for answering but I feel I don't understand it.

    Elfizm
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited October 2012
    Yes multi touch can be very difficult to understand. You have to basically fill the gaps between the two events. For a simple two touch system you need to keep track of who was touched first and second. This means that both actors will have a pair of duplicate rules that contain the logic for what you want to happen when they are touched. For this you also need to create index attributes, one for player1 and one for player2.

    Rule: when touch is pressed and attribute touch.count = 1

    Change attribute: player1.touchorder to 1

    (Rule inside this rule) when (any) attribute touch.count = 1 or attribute.player2.touchorder = 2
    Link any movements and such to touch1 inside this rule.

    (We add the other player to this because if that actor was assigned touch 2 and remains pressed it will hold touch2 even though the system touch count drops to 1. So that leaves touch1 unused so we need to be sure when you touch the other actor it gets assigned touch1 even though the system will now read two touches.)


    (Otherwise) change attribute: player1.touchorder to 0

    Duplicate rule

    Rule: when touch is pressed and attribute touch.count = 2 and attribute.player2touchorder (doesn't =) 2

    Change attribute: player1.touchorder

    Link any movements and such to touch 2

    (Otherwise) change attribute: player1.touchorder to 0

    Do the same for actor 2 only use the player2.touchorder attribute you created.

    This is tough logic to explain but I hope this helps.

  • HymloeHymloe Member Posts: 1,653
    I'm finding it really difficult to come up with a system that works for my game as well.

    I have a virtual DPad on the left, and a large "ShootBox" actor that fills the middle of the screen. I've been using TouchCount to assign an ID to each, but it falls apart if the player starts to hold down and release the various touch pads in certain ways.

    The player can press either one, either one at a time, or at the same time. The DPad controls the player movement. Tapping the Shootbox has the player shoot at that position.

    It all works fine, except when...

    * The player holds down the DPad (this becomes Touch1) and moves the character around.

    * The player holds down the Shootbox to shoot their weapons (this becomes Touch 2).

    * The player releases the DPad (while still holding down the Shootbox), then presses the DPad again. Now it still senses 2 touches, and so assigns Touch 2 to the DPad. Now the player starts to shoot towards the DPad (instead of towards the finger touching the Shootbox area), which is not my desired behaviour.


    It would be great if Game Salad itself could keep track of which touches are currently available, so that the actors can assign the lowest available touch count to a new touch, and then track it.

    I'm finding it hard to figure out a way to do this myself in my game. But I guess I can come up with a way... somehow.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Multi touch is very difficult. It took me a month to build a true three touch system. You can do it with code but you need to understand advanced logic.
  • ElfizmElfizm Member Posts: 489
    @Hymloe
    I attempted to get multi touch working but because it does take skill I could only make a fake multi touch game, in other words if would work but it was done in such a poor way you could tell. So I put that idea on side for now until i have the time to work on it full time with no other projects.

    But I do wish you the best of luck finding a solution :)
  • HymloeHymloe Member Posts: 1,653
    Yep, three touch is proving tricky.

    Especially if you have different touch areas around the screen, that need to be aware which touch they are, and also track the movement of the finger (taking X,Y input in real time). As well as some areas that don't have any touch sensitive content, but need to collaborate with touch sensitive areas to know how many touches are active.

    Anyway, I've kind of got something fairly good working for myself. Shall have to see how I go!

Sign In or Register to comment.