mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Added button property and methods for leftButtonReleased, rightButtonReleased and so on.
This commit is contained in:
parent
77859b1cdf
commit
0791ae10d2
1 changed files with 87 additions and 0 deletions
|
@ -103,6 +103,24 @@ var Pointer = new Class({
|
|||
*/
|
||||
this.camera = null;
|
||||
|
||||
/**
|
||||
* A read-only property that indicates which button was pressed, or released, on the pointer
|
||||
* during the most recent event. It is only set during `up` and `down` events.
|
||||
*
|
||||
* On Touch devices the value is always 0.
|
||||
*
|
||||
* Users may change the configuration of buttons on their pointing device so that if an event's button property
|
||||
* is zero, it may not have been caused by the button that is physically left–most on the pointing device;
|
||||
* however, it should behave as if the left button was clicked in the standard button layout.
|
||||
*
|
||||
* @name Phaser.Input.Pointer#button
|
||||
* @type {integer}
|
||||
* @readonly
|
||||
* @default 0
|
||||
* @since 3.18.0
|
||||
*/
|
||||
this.button = 0;
|
||||
|
||||
/**
|
||||
* 0: No button or un-initialized
|
||||
* 1: Left button
|
||||
|
@ -544,6 +562,8 @@ var Pointer = new Class({
|
|||
|
||||
this.event = event;
|
||||
|
||||
this.button = event.button;
|
||||
|
||||
this.upElement = event.target;
|
||||
|
||||
// Sets the local x/y properties
|
||||
|
@ -581,6 +601,8 @@ var Pointer = new Class({
|
|||
|
||||
this.event = event;
|
||||
|
||||
this.button = event.button;
|
||||
|
||||
this.downElement = event.target;
|
||||
|
||||
// Sets the local x/y properties
|
||||
|
@ -876,6 +898,71 @@ var Pointer = new Class({
|
|||
return (this.buttons & 16) ? true : false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if the left button was just released on this Pointer.
|
||||
*
|
||||
* @method Phaser.Input.Pointer#leftButtonReleased
|
||||
* @since 3.18.0
|
||||
*
|
||||
* @return {boolean} `true` if the left button was just released.
|
||||
*/
|
||||
leftButtonReleased: function ()
|
||||
{
|
||||
return (this.button === 0 && !this.isDown);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if the right button was just released on this Pointer.
|
||||
*
|
||||
* @method Phaser.Input.Pointer#rightButtonReleased
|
||||
* @since 3.18.0
|
||||
*
|
||||
* @return {boolean} `true` if the right button was just released.
|
||||
*/
|
||||
rightButtonReleased: function ()
|
||||
{
|
||||
return (this.button === 2 && !this.isDown);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if the middle button was just released on this Pointer.
|
||||
*
|
||||
* @method Phaser.Input.Pointer#middleButtonReleased
|
||||
* @since 3.18.0
|
||||
*
|
||||
* @return {boolean} `true` if the middle button was just released.
|
||||
*/
|
||||
middleButtonReleased: function ()
|
||||
{
|
||||
return (this.button === 1 && !this.isDown);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if the back button was just released on this Pointer.
|
||||
*
|
||||
* @method Phaser.Input.Pointer#backButtonReleased
|
||||
* @since 3.18.0
|
||||
*
|
||||
* @return {boolean} `true` if the back button was just released.
|
||||
*/
|
||||
backButtonReleased: function ()
|
||||
{
|
||||
return (this.button === 3 && !this.isDown);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if the forward button was just released on this Pointer.
|
||||
*
|
||||
* @method Phaser.Input.Pointer#forwardButtonReleased
|
||||
* @since 3.18.0
|
||||
*
|
||||
* @return {boolean} `true` if the forward button was just released.
|
||||
*/
|
||||
forwardButtonReleased: function ()
|
||||
{
|
||||
return (this.button === 4 && !this.isDown);
|
||||
},
|
||||
|
||||
/**
|
||||
* If the Pointer has a button pressed down at the time this method is called, it will return the
|
||||
* distance between the Pointer's `downX` and `downY` values and the current position.
|
||||
|
|
Loading…
Reference in a new issue