1

I'm trying to draw one line where it's end follows the mouse. Whenever I click there is a huge offset between the mouse pointer and the line end. I assume the coordinates are based on the screen coordinates rather than the window coordinates.

      var pointer = this.input.activePointer;
      if(pointer.isDown) {

        line.setTo(0,0, pointer.x, pointer.y)
      }

Update: The offset is of 100px (horizontal and vertical), any resolution screen. But I don't know why.

  • It's not really clear what your problem or error is. Is it that the line doesn't appear at the same position as the mouse cursor? – BdR Apr 09 '19 at 12:57
  • @BdR The line theoretically should end where the mouse is, however it end like 200 pixels to the left and top of the mouse cursor. If it is still not clear, let me know and I'll paste a picture here for clarifying. – Hola Soy Edu Feliz Navidad Apr 09 '19 at 15:55
  • It probably has to do with the `pointer.x` is relative to the page, not the canvas. So you have to correct the position for the bounding rectangle of the canvas. See this question https://stackoverflow.com/questions/17130395/real-mouse-position-in-canvas – BdR Apr 09 '19 at 18:28

0 Answers0