mirror of
https://github.com/wassname/phaser.git
synced 2026-07-15 01:11:26 +08:00
Merge pull request #167 from wKLV/dev
Mouse now knows what button is clicked
This commit is contained in:
+18
-1
@@ -41,6 +41,11 @@ Phaser.Mouse = function (game) {
|
||||
* @default
|
||||
*/
|
||||
this.mouseUpCallback = null;
|
||||
/**
|
||||
* @property {Description} mouseTypeDown - The type of click. -1 for not clicking
|
||||
* @default
|
||||
*/
|
||||
this.mouseTypeDown = -1;
|
||||
|
||||
/**
|
||||
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
|
||||
@@ -58,6 +63,11 @@ Phaser.Mouse = function (game) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Mouse.NO_BUTTON = -1;
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
@@ -76,6 +86,7 @@ Phaser.Mouse.MIDDLE_BUTTON = 1;
|
||||
*/
|
||||
Phaser.Mouse.RIGHT_BUTTON = 2;
|
||||
|
||||
|
||||
Phaser.Mouse.prototype = {
|
||||
|
||||
/**
|
||||
@@ -119,6 +130,10 @@ Phaser.Mouse.prototype = {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (event.which === 1) this.mouseTypeDown = Phaser.Mouse.LEFT_BUTTON;
|
||||
else if (event.which === 2) this.mouseTypeDown = Phaser.Mouse.MIDDLE_BUTTON;
|
||||
else if (event.which === 3) this.mouseTypeDown = Phaser.Mouse.RIGHT_BUTTON;
|
||||
|
||||
if (this.mouseDownCallback)
|
||||
{
|
||||
this.mouseDownCallback.call(this.callbackContext, event);
|
||||
@@ -169,6 +184,8 @@ Phaser.Mouse.prototype = {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
this.mouseTypeDown = Phaser.Mouse.NO_BUTTON;
|
||||
|
||||
if (this.mouseUpCallback)
|
||||
{
|
||||
this.mouseUpCallback.call(this.callbackContext, event);
|
||||
@@ -262,4 +279,4 @@ Phaser.Mouse.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user