Gamepad._created is a new private internal property that keeps track of when the instance was created. This is compared to the navigator timestamp in the update loop to avoid event spamming. Fix #4890.

This commit is contained in:
Richard Davey 2020-09-11 14:01:55 +01:00
parent 5ecdc3b4a2
commit 2acfbfbe71

View file

@ -313,6 +313,16 @@ var Gamepad = new Class({
* @since 3.10.0
*/
this.rightStick = new Vector2();
/**
* When was this Gamepad created? Used to avoid duplicate event spamming in the update loop.
*
* @name Phaser.Input.Gamepad.Gamepad#_created
* @type {number}
* @private
* @since 3.50.0
*/
this._created = performance.now();
},
/**
@ -420,6 +430,11 @@ var Gamepad = new Class({
*/
update: function (pad)
{
if (pad.timestamp < this._created)
{
return;
}
var i;
// Sync the button values