Canvas position of cursor image in different resolution screens

77 Views Asked by At

I am trying to make a multiplayer game in which the user will be playing the game in desktop screen and the same will be displayed in multiple screens. I have give a cursor image to display the position of the cursor in the mobile devices as well.

I am running into the problem of matching the position of cursor, there is an offset that is coming which is not displaying correctly in current screens and other screens. Any help can make my life easy.

Here is the code:

var Mouse_Pos;
Uicontainer.prototype.onMouseMove = function(event) {
  Mouse_Pos.x = event.x;
  Mouse_Pos.y = -event.y;
  Mouse_Pos.z = 0;
  this.Cursor.setLocalPosition(Mouse_Pos.x, Mouse_Pos.y, 0);
  //this i was exchanging with other players to match with their screen resolutions. 
  Cur_Pos_Upd = "cursorPos_" + (Mouse_Pos.x / (window.innerWidth)) + "_" + (Mouse_Pos.y / (window.innerHeight));
};

Thanks in advance.

0

There are 0 best solutions below