I’m currently working on a mouselook actuator for the BGE as a way to begin learning BGE development. So far, everything works perfectly. But (and this is probably going to sound dumb) I can’t shake a gut feeling that I’m doing things the wrong way in terms of getting the mouse and screen stuff.
First off, to get the mouse position I added a new function to KX_Scene that returns a pointer to the mouseManager for that scene which is then is passed to my actuator. I then added a function in the mousemanager that returns the X and Y position of the mouse. It does this by storing the mouse coordinates when the NextFrame() function is called in the mouseManager.
To get the screen’s height and width, as well as setting the mouse’s position to the centre of the screen I added another function to KX_Scene that returns a pointer to the canvas. This is passed to my actuator so that through the canvas I can get the screen dimensions and set the mouse position.
I did things this way because it seemed the most straightforward and required no code repetition.
I can’t say why, but something in me feels that it is not a good idea or practice to give an actuator access to the mouseManager or the scene’s canvas. I’m I just being stupid or is there a better way to do this?