In my game I need to use the mouse to select units.
However, I am encountering problems as I do not know how to get the coordinates of the click relative to the game, not to the window.
For example, if Unit 1 is at the (0,0) point of the game, it could be at any point on the window depending on how I pan and zoom the window, but I want the mouse click to return (0,0) no matter how I move the window as long as I click on the same spot.
Right now I am using:
override func mouseDown(with event: NSEvent) {
eventPos = event.location(in: self)
...
}
(The rest of the code does not matter for the mouse click location).
This is all inside a GameScene, which is an SKScene. So how do I get the location relative to the GameScene of the mouse click?