Information and functions for the mouse.
There are browsers that are not able to handle middle and right mouse buttons without problems.
gamvas. | Information and functions for the mouse. |
Variables | |
LEFT | Defines the left mouse button |
MIDDLE | Defines the middle mouse button |
RIGHT | Defines the right mouse button |
Functions | |
isPressed | Check if a mouse button is pressed |
getX | Returns the x position of the mouse over the canvas. |
getY | Returns the y position of the mouse over the canvas. |
getPosition | Returns the position of the mouse as gamvas.Vector2D |
exitEvent | return from a unhandled mouseevent on onMouse* functions |
getPosition: function( ev )
Returns the position of the mouse as gamvas.Vector2D
The position is relative to the canvas, so 0/0 is the upper left corner and canvaswidth/canvasheight is the lower right corner.
To convert the canvas mouse position the the current states world use <gamvas.camera.toWorld> from this.camera of the current state
exitEvent: function()
return from a unhandled mouseevent on onMouse* functions
gamvas.State.onMouseDown gamvas.State.onMouseUp gamvas.State.onMouseMove
Defines the left mouse button
LEFT: 0
Defines the middle mouse button
MIDDLE: 1
Defines the right mouse button
RIGHT: 2
Check if a mouse button is pressed
isPressed: function( k )
Returns the x position of the mouse over the canvas.
getX: function( ev )
Returns the y position of the mouse over the canvas.
getY: function( ev )
Returns the position of the mouse as gamvas.Vector2D
getPosition: function( ev )
return from a unhandled mouseevent on onMouse* functions
exitEvent: function()
A mouse button was pressed
onMouseDown: function( button, x, y, ev )
A mouse button was released
onMouseUp: function( button, x, y, ev )
The mouse was moved
onMouseMove: function( x, y, ev )