Crafty.lastEvent

Check which mouse event occured most recently (useful for determining mouse position in every frame).

The native MouseEvent is augmented with additional properties.

Example

// (x,y) coordinates of newest mouse event in web-browser (screen) space
Crafty.lastEvent.clientX
Crafty.lastEvent.clientY

//(x,y) coordinates of newest mouse event in world (default viewport) space
Crafty.lastEvent.realX
Crafty.lastEvent.realY

// Normalized mouse button according to Crafty.mouseButtons:
// Crafty.mouseButtons.LEFT, Crafty.mouseButtons.RIGHT or Crafty.mouseButtons.MIDDLE
Crafty.lastEvent.mouseButton