Add TimeStep#pauseDuration

Pass in Phaser.Core.Events#RESUME
This commit is contained in:
samme 2024-07-16 09:28:44 -07:00
parent 23e287ef0e
commit 2824185784
3 changed files with 16 additions and 2 deletions

View file

@ -630,7 +630,7 @@ var Game = new Class({
{
this.loop.resume();
this.events.emit(Events.RESUME);
this.events.emit(Events.RESUME, this.loop.pauseDuration);
},
/**

View file

@ -304,6 +304,17 @@ var TimeStep = new Class({
*/
this.inFocus = true;
/**
* The duration of the most recent game pause, if any, in ms.
*
* @name Phaser.Core.TimeStep#pauseDuration
* @type {number}
* @readonly
* @default 0
* @since 3.85.0
*/
this.pauseDuration = 0;
/**
* The timestamp at which the game became paused, as determined by the Page Visibility API.
*
@ -469,7 +480,8 @@ var TimeStep = new Class({
{
this.resetDelta();
this.startTime += this.time - this._pauseTime;
this.pauseDuration = this.time - this._pauseTime;
this.startTime += this.pauseDuration;
},
/**

View file

@ -12,5 +12,7 @@
* @event Phaser.Core.Events#RESUME
* @type {string}
* @since 3.0.0
*
* @param {number} pauseDuration - The duration, in ms, that the game was paused for.
*/
module.exports = 'resume';