Im trying to do a simple 2 player game of pong where you drag the rackets up an down to hit the ball.
The problem is that I can't drag the two at once. Is there any way to solve this? I've thought of making it so depending on the ball x one or the other racket is enabled but you could still block the other player by pressing the screen.
I did a little work on this problem in this project:
I work mostly in the emulator these days, so I can't easily test these possible workarounds that I hadn't thought of when I did that project:
Add 2 thin Canvases to the sides of the main Canvas, for paddle control. That gives you 2 more drag events you can use to control the 2 paddles separately. Ignore drags on the central canvas except maybe to start the ball moving. This might not work if it requires multitouch.
Use a single canvas, and the Canvas drag event to control the paddle of the player whose paddle is closest to the contact point of the drag, and only if the ball is headed to that player's side. Use x values for measurement of closest.
you see, the problem is not that they don't work at the same time, the problem is that screens don't usually respond correctly when you touch at two different points.
Im asking if there is a way to drag at the same time in two different spots
Here's an alternative game mechanic to try for lack of multitouch:
Respond only to Canvas.TouchDown, and have the respective paddles head towards their respective impact zones at a speed proportional to their distance from the touch point.
That translates the multitouch problem into a camping problem:
Does holding down your finger on the canvas block subsequent TouchDown events elsewhere?
It does not answer your original question, but it might give you something to work with.
Thanks, although it is not what I initially wanted, it works now. You could technically still block the other player by just pressing down yourself but now it won't happen accidentally