Interface: mouse

MC.mouse


The MC.mouse object contains all mouse related variables.
Upon initialisation it sets up document event listeners for mousemove, mouseup, mousedown & wheel
The following functions are defined, but empty, for Developers to customise (see Example)
(a) onClick() & onClickUp() fired when ANY mouse button is depressed or released
(b) onClickL() & onClickUpL() as above, Left Mouse Button only
(c) onClickM() & onClickUpM() as above, Middle Mouse Button only
(d) onClickR() & onClickUpR() as above, Right Mouse Button only.
CAUTION: most browsers have build in RH button features
(e) wheelUp() & wheelDown() fires when the mouse wheel is scrolled.
CAUTION: works for Chrome, support varies for other browsers
Properties:
Name Type Description
pos MC.Point Current mouse screen coordinates
clickStart MC.Point Screen coordinates of ANY mouse button down click
clickFinish MC.Point Screen coordinates of ANY mouse button release
mouseDown Boolean true if ANY mouse button is currently depressed, else false
clickStartL MC.Point Screen coordinates of the LEFT mouse button down click
clickFinishL MC.Point Screen coordinates of the LEFT mouse button release
mouseDownL Boolean true if LEFT mouse button is currently depressed, else false
clickStartM MC.Point Screen coordinates of the MIDDLE mouse button down click
clickFinishM MC.Point Screen coordinates of the MIDDLE button release
mouseDownL Boolean true if MIDDLE mouse button is currently depressed, else false
clickStartR MC.Point Screen coordinates of the RIGHT mouse button down click
clickFinishR MC.Point Screen coordinates of the RIGHT button release
mouseDownL Boolean true if RIGHT mouse button is currently depressed, else false
Source:

Example

MC.mouse.onClickL = function () {
   console.log("Left Mouse Clicked");
   mySprite.moveTo(MC.mouse.clickStartL);
};

MC.mouse.wheelUp = function () {
   if (mySprite.hit(MC.mouse.pos)) {
       mySprite.scale += 0.2;
   }
};

Methods

(static) init()


Used to Initialise the MC.mouse object, sets up properties and event listeners
Called automatically by the MC.game.init() method
Source: