How do I get mouse coordinated under C++? I can see only python example in manual, and can’t find similar functions in include files.
I’m trying to get coordinates so I can move actor (player) with mouse, but also with some restrictions (only one axis for example). If someone know the way to do it, please tell me too.
I’ve translated the relevant part of that manual chapter to c++.
// It's a good idea to check that the window hasn't just been closed,
// otherwise you could get an assertion on exit.
int x = window->get_graphics_window()->get_pointer(0).get_x();
int y = window->get_graphics_window()->get_pointer(0).get_y();
EDIT: Actually, in my code I also check that get_graphics_window() doesn’t return null first, this is what I do:
GraphicsWindow *gwin = window->get_graphics_window();
thisMouseX = gwin->get_pointer(0).get_x();
thisMouseY = gwin->get_pointer(0).get_y();
I did that to avoid an assertion, but I don’t remember if I got the assertion on window == NULL or on graphicWindow == NULL.
Thanks for help It’s working