Pointer fixes for Linux FireFox (#1932 #1944)

This commit is contained in:
photonstorm 2015-07-28 14:18:23 +01:00
parent cad0338449
commit 962066102c
14 changed files with 545 additions and 305 deletions

View file

@ -249,6 +249,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
### Updates ### Updates
* TypeScript definitions fixes and updates (thanks @clark-stevenson @shivinsky) * TypeScript definitions fixes and updates (thanks @clark-stevenson @shivinsky)
* JSDoc typo fixes (thanks @DrkSephy)
* TilemapLayer - Fixed unmatched `context.save` and `context.restore` calls (thanks @MortimerGoro #1934) * TilemapLayer - Fixed unmatched `context.save` and `context.restore` calls (thanks @MortimerGoro #1934)
* Cache.getFrame has a new `cache` parameter (that defaults to the Image cache, but can be changed to any other) * Cache.getFrame has a new `cache` parameter (that defaults to the Image cache, but can be changed to any other)
* Cache.getFrameCount has a new `cache` parameter (that defaults to the Image cache, but can be changed to any other) * Cache.getFrameCount has a new `cache` parameter (that defaults to the Image cache, but can be changed to any other)

View file

@ -7,7 +7,7 @@
* *
* Phaser - http://phaser.io * Phaser - http://phaser.io
* *
* v2.4.2 "Altara" - Built: Mon Jul 27 2015 13:35:18 * v2.4.2 "Altara" - Built: Tue Jul 28 2015 14:17:06
* *
* By Richard Davey http://www.photonstorm.com @photonstorm * By Richard Davey http://www.photonstorm.com @photonstorm
* *
@ -28225,6 +28225,94 @@ Phaser.Pointer.prototype = {
}, },
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsDown
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsDown: function (buttons, event) {
// Note: These are bitwise checks, not booleans
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{
this.leftButton.start(event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
},
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsUp
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsUp: function (button, event) {
// Note: These are bitwise checks, not booleans
if (button === Phaser.Mouse.LEFT_BUTTON)
{
this.leftButton.stop(event);
}
if (button === Phaser.Mouse.RIGHT_BUTTON)
{
this.rightButton.stop(event);
}
if (button === Phaser.Mouse.MIDDLE_BUTTON)
{
this.middleButton.stop(event);
}
if (button === Phaser.Mouse.BACK_BUTTON)
{
this.backButton.stop(event);
}
if (button === Phaser.Mouse.FORWARD_BUTTON)
{
this.forwardButton.stop(event);
}
if (button === 5)
{
this.eraserButton.stop(event);
}
},
/** /**
* Called when the event.buttons property changes from zero. * Called when the event.buttons property changes from zero.
* Contains a button bitmask. * Contains a button bitmask.
@ -28237,73 +28325,23 @@ Phaser.Pointer.prototype = {
this.button = event.button; this.button = event.button;
// This is tested back to IE9, but possibly some browsers may report this differently. var down = (event.type.toLowerCase().substr(-4) === 'down');
// If you find one, please tell us!
var buttons = event.buttons;
if (buttons !== undefined) if (event.buttons !== undefined)
{ {
// Note: These are bitwise checks, not booleans if (down)
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{ {
this.leftButton.start(event); this.processButtonsDown(event.buttons, event);
} }
else else
{ {
this.leftButton.stop(event); this.processButtonsUp(event.button, event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
else
{
this.rightButton.stop(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
else
{
this.middleButton.stop(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
else
{
this.backButton.stop(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
else
{
this.forwardButton.stop(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
else
{
this.eraserButton.stop(event);
} }
} }
else else
{ {
// No buttons property (like Safari on OSX when using a trackpad) // No buttons property (like Safari on OSX when using a trackpad)
if (down)
if (event.type === 'mousedown')
{ {
this.leftButton.start(event); this.leftButton.start(event);
} }
@ -28316,6 +28354,7 @@ Phaser.Pointer.prototype = {
// On OS X (and other devices with trackpads) you have to press CTRL + the pad // On OS X (and other devices with trackpads) you have to press CTRL + the pad
// to initiate a right-click event, so we'll check for that here // to initiate a right-click event, so we'll check for that here
if (event.ctrlKey && this.leftButton.isDown) if (event.ctrlKey && this.leftButton.isDown)
{ {
this.rightButton.start(event); this.rightButton.start(event);
@ -28339,6 +28378,8 @@ Phaser.Pointer.prototype = {
*/ */
start: function (event) { start: function (event) {
// console.log(event);
if (event['pointerId']) if (event['pointerId'])
{ {
this.pointerId = event.pointerId; this.pointerId = event.pointerId;
@ -57219,6 +57260,10 @@ Phaser.Cache.prototype = {
/** /**
* Removes a sound from the cache. * Removes a sound from the cache.
* *
* If any `Phaser.Sound` objects use the audio file in the cache that you remove with this method, they will
* _automatically_ destroy themselves. If you wish to have full control over when Sounds are destroyed then
* you must finish your house-keeping and destroy them all yourself first, before calling this method.
*
* Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere
* then it will persist in memory. * then it will persist in memory.
* *
@ -61158,6 +61203,12 @@ Phaser.Sound.prototype = {
*/ */
update: function () { update: function () {
if (!this.game.cache.checkSoundKey(this.key))
{
this.destroy();
return;
}
if (this.isDecoded && !this._onDecodedEventDispatched) if (this.isDecoded && !this._onDecodedEventDispatched)
{ {
this.onDecoded.dispatch(this); this.onDecoded.dispatch(this);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* *
* Phaser - http://phaser.io * Phaser - http://phaser.io
* *
* v2.4.2 "Altara" - Built: Mon Jul 27 2015 13:35:35 * v2.4.2 "Altara" - Built: Tue Jul 28 2015 14:17:23
* *
* By Richard Davey http://www.photonstorm.com @photonstorm * By Richard Davey http://www.photonstorm.com @photonstorm
* *
@ -27031,6 +27031,94 @@ Phaser.Pointer.prototype = {
}, },
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsDown
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsDown: function (buttons, event) {
// Note: These are bitwise checks, not booleans
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{
this.leftButton.start(event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
},
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsUp
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsUp: function (button, event) {
// Note: These are bitwise checks, not booleans
if (button === Phaser.Mouse.LEFT_BUTTON)
{
this.leftButton.stop(event);
}
if (button === Phaser.Mouse.RIGHT_BUTTON)
{
this.rightButton.stop(event);
}
if (button === Phaser.Mouse.MIDDLE_BUTTON)
{
this.middleButton.stop(event);
}
if (button === Phaser.Mouse.BACK_BUTTON)
{
this.backButton.stop(event);
}
if (button === Phaser.Mouse.FORWARD_BUTTON)
{
this.forwardButton.stop(event);
}
if (button === 5)
{
this.eraserButton.stop(event);
}
},
/** /**
* Called when the event.buttons property changes from zero. * Called when the event.buttons property changes from zero.
* Contains a button bitmask. * Contains a button bitmask.
@ -27043,73 +27131,23 @@ Phaser.Pointer.prototype = {
this.button = event.button; this.button = event.button;
// This is tested back to IE9, but possibly some browsers may report this differently. var down = (event.type.toLowerCase().substr(-4) === 'down');
// If you find one, please tell us!
var buttons = event.buttons;
if (buttons !== undefined) if (event.buttons !== undefined)
{ {
// Note: These are bitwise checks, not booleans if (down)
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{ {
this.leftButton.start(event); this.processButtonsDown(event.buttons, event);
} }
else else
{ {
this.leftButton.stop(event); this.processButtonsUp(event.button, event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
else
{
this.rightButton.stop(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
else
{
this.middleButton.stop(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
else
{
this.backButton.stop(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
else
{
this.forwardButton.stop(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
else
{
this.eraserButton.stop(event);
} }
} }
else else
{ {
// No buttons property (like Safari on OSX when using a trackpad) // No buttons property (like Safari on OSX when using a trackpad)
if (down)
if (event.type === 'mousedown')
{ {
this.leftButton.start(event); this.leftButton.start(event);
} }
@ -27122,6 +27160,7 @@ Phaser.Pointer.prototype = {
// On OS X (and other devices with trackpads) you have to press CTRL + the pad // On OS X (and other devices with trackpads) you have to press CTRL + the pad
// to initiate a right-click event, so we'll check for that here // to initiate a right-click event, so we'll check for that here
if (event.ctrlKey && this.leftButton.isDown) if (event.ctrlKey && this.leftButton.isDown)
{ {
this.rightButton.start(event); this.rightButton.start(event);
@ -27145,6 +27184,8 @@ Phaser.Pointer.prototype = {
*/ */
start: function (event) { start: function (event) {
// console.log(event);
if (event['pointerId']) if (event['pointerId'])
{ {
this.pointerId = event.pointerId; this.pointerId = event.pointerId;
@ -43959,6 +44000,10 @@ Phaser.Cache.prototype = {
/** /**
* Removes a sound from the cache. * Removes a sound from the cache.
* *
* If any `Phaser.Sound` objects use the audio file in the cache that you remove with this method, they will
* _automatically_ destroy themselves. If you wish to have full control over when Sounds are destroyed then
* you must finish your house-keeping and destroy them all yourself first, before calling this method.
*
* Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere
* then it will persist in memory. * then it will persist in memory.
* *

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* *
* Phaser - http://phaser.io * Phaser - http://phaser.io
* *
* v2.4.2 "Altara" - Built: Mon Jul 27 2015 13:35:27 * v2.4.2 "Altara" - Built: Tue Jul 28 2015 14:17:15
* *
* By Richard Davey http://www.photonstorm.com @photonstorm * By Richard Davey http://www.photonstorm.com @photonstorm
* *
@ -28225,6 +28225,94 @@ Phaser.Pointer.prototype = {
}, },
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsDown
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsDown: function (buttons, event) {
// Note: These are bitwise checks, not booleans
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{
this.leftButton.start(event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
},
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsUp
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsUp: function (button, event) {
// Note: These are bitwise checks, not booleans
if (button === Phaser.Mouse.LEFT_BUTTON)
{
this.leftButton.stop(event);
}
if (button === Phaser.Mouse.RIGHT_BUTTON)
{
this.rightButton.stop(event);
}
if (button === Phaser.Mouse.MIDDLE_BUTTON)
{
this.middleButton.stop(event);
}
if (button === Phaser.Mouse.BACK_BUTTON)
{
this.backButton.stop(event);
}
if (button === Phaser.Mouse.FORWARD_BUTTON)
{
this.forwardButton.stop(event);
}
if (button === 5)
{
this.eraserButton.stop(event);
}
},
/** /**
* Called when the event.buttons property changes from zero. * Called when the event.buttons property changes from zero.
* Contains a button bitmask. * Contains a button bitmask.
@ -28237,73 +28325,23 @@ Phaser.Pointer.prototype = {
this.button = event.button; this.button = event.button;
// This is tested back to IE9, but possibly some browsers may report this differently. var down = (event.type.toLowerCase().substr(-4) === 'down');
// If you find one, please tell us!
var buttons = event.buttons;
if (buttons !== undefined) if (event.buttons !== undefined)
{ {
// Note: These are bitwise checks, not booleans if (down)
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{ {
this.leftButton.start(event); this.processButtonsDown(event.buttons, event);
} }
else else
{ {
this.leftButton.stop(event); this.processButtonsUp(event.button, event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
else
{
this.rightButton.stop(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
else
{
this.middleButton.stop(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
else
{
this.backButton.stop(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
else
{
this.forwardButton.stop(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
else
{
this.eraserButton.stop(event);
} }
} }
else else
{ {
// No buttons property (like Safari on OSX when using a trackpad) // No buttons property (like Safari on OSX when using a trackpad)
if (down)
if (event.type === 'mousedown')
{ {
this.leftButton.start(event); this.leftButton.start(event);
} }
@ -28316,6 +28354,7 @@ Phaser.Pointer.prototype = {
// On OS X (and other devices with trackpads) you have to press CTRL + the pad // On OS X (and other devices with trackpads) you have to press CTRL + the pad
// to initiate a right-click event, so we'll check for that here // to initiate a right-click event, so we'll check for that here
if (event.ctrlKey && this.leftButton.isDown) if (event.ctrlKey && this.leftButton.isDown)
{ {
this.rightButton.start(event); this.rightButton.start(event);
@ -28339,6 +28378,8 @@ Phaser.Pointer.prototype = {
*/ */
start: function (event) { start: function (event) {
// console.log(event);
if (event['pointerId']) if (event['pointerId'])
{ {
this.pointerId = event.pointerId; this.pointerId = event.pointerId;
@ -57219,6 +57260,10 @@ Phaser.Cache.prototype = {
/** /**
* Removes a sound from the cache. * Removes a sound from the cache.
* *
* If any `Phaser.Sound` objects use the audio file in the cache that you remove with this method, they will
* _automatically_ destroy themselves. If you wish to have full control over when Sounds are destroyed then
* you must finish your house-keeping and destroy them all yourself first, before calling this method.
*
* Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere
* then it will persist in memory. * then it will persist in memory.
* *
@ -61158,6 +61203,12 @@ Phaser.Sound.prototype = {
*/ */
update: function () { update: function () {
if (!this.game.cache.checkSoundKey(this.key))
{
this.destroy();
return;
}
if (this.isDecoded && !this._onDecodedEventDispatched) if (this.isDecoded && !this._onDecodedEventDispatched)
{ {
this.onDecoded.dispatch(this); this.onDecoded.dispatch(this);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* *
* Phaser - http://phaser.io * Phaser - http://phaser.io
* *
* v2.4.2 "Altara" - Built: Mon Jul 27 2015 13:35:06 * v2.4.2 "Altara" - Built: Tue Jul 28 2015 14:16:55
* *
* By Richard Davey http://www.photonstorm.com @photonstorm * By Richard Davey http://www.photonstorm.com @photonstorm
* *
@ -41838,6 +41838,94 @@ Phaser.Pointer.prototype = {
}, },
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsDown
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsDown: function (buttons, event) {
// Note: These are bitwise checks, not booleans
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{
this.leftButton.start(event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
},
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsUp
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsUp: function (button, event) {
// Note: These are bitwise checks, not booleans
if (button === Phaser.Mouse.LEFT_BUTTON)
{
this.leftButton.stop(event);
}
if (button === Phaser.Mouse.RIGHT_BUTTON)
{
this.rightButton.stop(event);
}
if (button === Phaser.Mouse.MIDDLE_BUTTON)
{
this.middleButton.stop(event);
}
if (button === Phaser.Mouse.BACK_BUTTON)
{
this.backButton.stop(event);
}
if (button === Phaser.Mouse.FORWARD_BUTTON)
{
this.forwardButton.stop(event);
}
if (button === 5)
{
this.eraserButton.stop(event);
}
},
/** /**
* Called when the event.buttons property changes from zero. * Called when the event.buttons property changes from zero.
* Contains a button bitmask. * Contains a button bitmask.
@ -41850,73 +41938,23 @@ Phaser.Pointer.prototype = {
this.button = event.button; this.button = event.button;
// This is tested back to IE9, but possibly some browsers may report this differently. var down = (event.type.toLowerCase().substr(-4) === 'down');
// If you find one, please tell us!
var buttons = event.buttons;
if (buttons !== undefined) if (event.buttons !== undefined)
{ {
// Note: These are bitwise checks, not booleans if (down)
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{ {
this.leftButton.start(event); this.processButtonsDown(event.buttons, event);
} }
else else
{ {
this.leftButton.stop(event); this.processButtonsUp(event.button, event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
else
{
this.rightButton.stop(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
else
{
this.middleButton.stop(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
else
{
this.backButton.stop(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
else
{
this.forwardButton.stop(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
else
{
this.eraserButton.stop(event);
} }
} }
else else
{ {
// No buttons property (like Safari on OSX when using a trackpad) // No buttons property (like Safari on OSX when using a trackpad)
if (down)
if (event.type === 'mousedown')
{ {
this.leftButton.start(event); this.leftButton.start(event);
} }
@ -41929,6 +41967,7 @@ Phaser.Pointer.prototype = {
// On OS X (and other devices with trackpads) you have to press CTRL + the pad // On OS X (and other devices with trackpads) you have to press CTRL + the pad
// to initiate a right-click event, so we'll check for that here // to initiate a right-click event, so we'll check for that here
if (event.ctrlKey && this.leftButton.isDown) if (event.ctrlKey && this.leftButton.isDown)
{ {
this.rightButton.start(event); this.rightButton.start(event);
@ -41952,6 +41991,8 @@ Phaser.Pointer.prototype = {
*/ */
start: function (event) { start: function (event) {
// console.log(event);
if (event['pointerId']) if (event['pointerId'])
{ {
this.pointerId = event.pointerId; this.pointerId = event.pointerId;
@ -70832,6 +70873,10 @@ Phaser.Cache.prototype = {
/** /**
* Removes a sound from the cache. * Removes a sound from the cache.
* *
* If any `Phaser.Sound` objects use the audio file in the cache that you remove with this method, they will
* _automatically_ destroy themselves. If you wish to have full control over when Sounds are destroyed then
* you must finish your house-keeping and destroy them all yourself first, before calling this method.
*
* Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere
* then it will persist in memory. * then it will persist in memory.
* *
@ -74771,6 +74816,12 @@ Phaser.Sound.prototype = {
*/ */
update: function () { update: function () {
if (!this.game.cache.checkSoundKey(this.key))
{
this.destroy();
return;
}
if (this.isDecoded && !this._onDecodedEventDispatched) if (this.isDecoded && !this._onDecodedEventDispatched)
{ {
this.onDecoded.dispatch(this); this.onDecoded.dispatch(this);

File diff suppressed because one or more lines are too long

6
build/phaser.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -419,6 +419,94 @@ Phaser.Pointer.prototype = {
}, },
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsDown
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsDown: function (buttons, event) {
// Note: These are bitwise checks, not booleans
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{
this.leftButton.start(event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
},
/**
* Called by updateButtons.
*
* @method Phaser.Pointer#processButtonsUp
* @private
* @param {integer} buttons - The DOM event.buttons property.
* @param {MouseEvent} event - The DOM event.
*/
processButtonsUp: function (button, event) {
// Note: These are bitwise checks, not booleans
if (button === Phaser.Mouse.LEFT_BUTTON)
{
this.leftButton.stop(event);
}
if (button === Phaser.Mouse.RIGHT_BUTTON)
{
this.rightButton.stop(event);
}
if (button === Phaser.Mouse.MIDDLE_BUTTON)
{
this.middleButton.stop(event);
}
if (button === Phaser.Mouse.BACK_BUTTON)
{
this.backButton.stop(event);
}
if (button === Phaser.Mouse.FORWARD_BUTTON)
{
this.forwardButton.stop(event);
}
if (button === 5)
{
this.eraserButton.stop(event);
}
},
/** /**
* Called when the event.buttons property changes from zero. * Called when the event.buttons property changes from zero.
* Contains a button bitmask. * Contains a button bitmask.
@ -431,73 +519,23 @@ Phaser.Pointer.prototype = {
this.button = event.button; this.button = event.button;
// This is tested back to IE9, but possibly some browsers may report this differently. var down = (event.type.toLowerCase().substr(-4) === 'down');
// If you find one, please tell us!
var buttons = event.buttons;
if (buttons !== undefined) if (event.buttons !== undefined)
{ {
// Note: These are bitwise checks, not booleans if (down)
if (Phaser.Pointer.LEFT_BUTTON & buttons)
{ {
this.leftButton.start(event); this.processButtonsDown(event.buttons, event);
} }
else else
{ {
this.leftButton.stop(event); this.processButtonsUp(event.button, event);
}
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
{
this.rightButton.start(event);
}
else
{
this.rightButton.stop(event);
}
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
{
this.middleButton.start(event);
}
else
{
this.middleButton.stop(event);
}
if (Phaser.Pointer.BACK_BUTTON & buttons)
{
this.backButton.start(event);
}
else
{
this.backButton.stop(event);
}
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
{
this.forwardButton.start(event);
}
else
{
this.forwardButton.stop(event);
}
if (Phaser.Pointer.ERASER_BUTTON & buttons)
{
this.eraserButton.start(event);
}
else
{
this.eraserButton.stop(event);
} }
} }
else else
{ {
// No buttons property (like Safari on OSX when using a trackpad) // No buttons property (like Safari on OSX when using a trackpad)
if (down)
if (event.type === 'mousedown')
{ {
this.leftButton.start(event); this.leftButton.start(event);
} }
@ -510,6 +548,7 @@ Phaser.Pointer.prototype = {
// On OS X (and other devices with trackpads) you have to press CTRL + the pad // On OS X (and other devices with trackpads) you have to press CTRL + the pad
// to initiate a right-click event, so we'll check for that here // to initiate a right-click event, so we'll check for that here
if (event.ctrlKey && this.leftButton.isDown) if (event.ctrlKey && this.leftButton.isDown)
{ {
this.rightButton.start(event); this.rightButton.start(event);
@ -533,6 +572,8 @@ Phaser.Pointer.prototype = {
*/ */
start: function (event) { start: function (event) {
// console.log(event);
if (event['pointerId']) if (event['pointerId'])
{ {
this.pointerId = event.pointerId; this.pointerId = event.pointerId;