Mouse Sensor Left Button: position

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

Type: 
  • List [xPosition, yPosition]

xPosition:

  • x position of the mouse pointer in the game window.
  • Type:  integer 
yPosition:
  • y position of the mouse pointer in the game window.
  • Type:  integer
Mouse Sensor:
  • Left mouse button pressed:  One positive pulse is sent to the connected controller(s).
  • Left mouse button released:  One negative pulse is sent to the connected controller(s).
Sample Code


################  Get mouse pointer position
 
# import bge module

import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Trigger

sen = cont.sensors["Trigger"]

# get mouse pointer position
pos = sen.position