I have a bug/issue in my game - that I'm having troubles to sort out.
My game rely on the coordinates for the Mouse or Touch - but their mechanics are a bit different.
I have a 2 player realtime multiplayer game - and I've used the Multiplayer - Real-time game, Example in Construct as a template when I created my game.
It works basically like this:
When it's a players turn, they supposed to throw something. They aim by clicking and holding down mouse-button and drags in a direction. When they let go of the mouse-button they throw their object.
What happens are that a small cross (sprite) gets positioned where the mouse clicked, then a line (sprite) gets positioned at the same position - and the line.angle gets pointed towards the Mouse.X & Mouse.Y ..The line.width also get set, and it's the distance between where the mouse clicked, and where the Mouse.X & Mouse.Y are. If the player are on a touch-device it's the Touch.X & Touch.Y instead of the Mouse.X and Mouse.Y
When the player release mouse-button OR stop touching the touch-device: an object gets thrown. The object gets thrown in a direction and uses the line.angle for that, and the force to throw the object it uses the width of the line.
So the angle and the width are very important for this to work.
This works very nice, both for Player 1 (the host) and Player 2 (the peer) but NOT if Player 2 are on a Touch-Device?
However it works on a touch-device if you Host the game ( you are the Player 1). But it does not work if the touch-device are the Peer ( Player 2 ).
My problem - when I've researched this is that the way the Mouse-mechanics vs the Touch-mechanics works is that: On a Mouse button released - the mouse-cursor ( the Mouse.X and Mouse.Y ) are at the same place ...just where you released the mouse-button.
But on a touch device: On touch end the Touch.X and Touch.Y get's set to Touch.X = 0 Touch.Y = 0
This is a problem for me in my game, as I use the angle of my line for the direction to throw my object. And I use the width of the line as a Force to throw the object.
If the Touch.X & Y gets set to 0,0 before I may throw my object, it's not good.
I believe it may have to do with an multiplayer on client update issue.
The Peer manages to set the Touch.X & Y back to 0,0 before construct can perform the actions for throwing the object.
As the line.width and line.angle uses the Touch.X & Y coordinates ...This phenomenon really screws things up.
As the multiplayer example, I use lookx and looky input values for the Mouse.X & Y. And I've done the same, but created other input-value-tags, for the Touch.X & Y
I use the Common group, as in the multiplayer example, to perform my actions when the input-bit are set to 1 or 0. ( In the example you fire your laser )
It have been easier, and worked so good but I may have to do this somehow in the Host group - cause I may feel construct will not be able to sync stuff correctly. But it will be much more troublesome to sort all the things out that needs to be done. For example I have things that needs to get flipped and mirrored, depending on if you are the Host or Peer ( Player 1 or 2 ). Also I need to use the pin behaviour. And some more stuff, that's hard to make work for the peer unless you broadcast multiplayer-messages from the Host to the Peer. And this gets very disorderly so quickly, I rather avoid it.
Has anyone had similar issues like this or having idea´s on how to do this in a better way?
Thanks a Million!