Mouse: position

position
  • Returns the position of the mouse pointer on the game window.

Return Type:

  • list [ xPos, yPos ]

xPos:

  • x position of the mouse
  • Type:  float number
  • Range:  0.00 to 1.00
  • 0.00 = Left side of game window
  • 1.00 = Right side of game window
yPos:
  • y position of the mouse
  • Type:  float number
  • Range:  0.00 to 1.00
  • 0.00 = Top of game window
  • 1.00 = Bottom of game window
Note:
  • bge.logic.mouse.position does not use the Mouse Sensor.
Sample Code

################## get the position of the mouse pointer

# import bge
import bge

# get the mouse
my_mouse = bge.logic.mouse

# get the mouse position
pos = my_mouse.position