Touch order

redonix76redonix76 Member Posts: 24
edited March 2012 in Working with GS (Mac)
Hey guys, Is there a way to specify touch order or to have an actor always have touch 1 no matter what? I have an actor that's constrained to my touch. I also have a fire button that can be held down to auto fire.

Problem is, if I hold down on my hero, then hold down my fire button then get go of my hero, the actor will automatically snap to my fire button. Now this is also true if I touch and hold down anywhere on screen. It's really annoying especially in a fast paced game.

Is there an easy way to fix this? Thanks in advance!

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    If you study the official GS control template found in the creator's start screen you will see how they handle multi-touch issues like the one you describe. The idea is to create a small invisible actor for each touch. So for iPhone you'll want 5 actors. Then in your main actor you check if it is overlapping with those actors. If it is overlapping with the actor called touch1 then constrain to touch.1.x and y. But if it is overlapping with the actor you named touch2 then you constrain it to touch.1.x and y , etc.
  • redonix76redonix76 Member Posts: 24
    Hey Scitunes thanks for the help. So I want to created these 5 invisible actors that is constrained to my touch, then have my main actor constrained to that actor if overlapping is true? Each of those 5 will be assined to the different touches from 1 - 5 correct?

    I'll have to go over the official GS control template again...It's kinda intimidating when I first looked at it and had no idea whats going on. I only have 2 buttons and 1 actor constrained to touch so hopefully it wont be as complicated.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    No don't constrain the main actor to the invisible actors. The invisible actors only serve the purpose of telling the main actor which touch is being used to control it. So if it overlaps with actor1 constrain main actor to game.touch.1.x and y if it overlaps with actor2 constrain to game.touch.2.x and Y etc.

    Here's another possible method that could be easier and a bit more effectient. If your button that is causing the problem is in the lower left corner you could have a rule in the actor when touch.position.x is > 100 (size of the button) AND touch.position.Y is > 100 constrain to touch1 x and y OTHERWISE constrain to touch 2 X and Y

    something like that might also work for you if you think that only two fingers will ever be used to play your game
  • redonix76redonix76 Member Posts: 24
    Hey Scitunes, thanks! yeah 2 touches at any one time is all I need! I'll try out this easier method and see if it works better...I can definitely understand it! I'll keep you posted, thank again!!
  • redonix76redonix76 Member Posts: 24
    Hi TSB, thanks again for the help. Do I need to put the 2 rules for both my actors or just my main actor that's being touch controlled?
  • redonix76redonix76 Member Posts: 24
    Hi TSB, Your method works great! The new problem is that if my finger moves the actor near a corner, the actor snaps to that corner and if I let go, it disappears!. Have you seen this problem before?

    If there a way to have collision while using your touch order method? Thanks!!
Sign In or Register to comment.