Merge pull request #6867 from samme/feature/timestep-pauseDuration

Add TimeStep#pauseDuration, pass in Phaser.Core.Events#RESUME
This commit is contained in:
Richard Davey 2024-07-18 20:34:57 +01:00 committed by GitHub
commit 14429786a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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';