mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 07:04:31 +00:00
Add TimeStep#pauseDuration
Pass in Phaser.Core.Events#RESUME
This commit is contained in:
parent
23e287ef0e
commit
2824185784
3 changed files with 16 additions and 2 deletions
|
@ -630,7 +630,7 @@ var Game = new Class({
|
|||
{
|
||||
this.loop.resume();
|
||||
|
||||
this.events.emit(Events.RESUME);
|
||||
this.events.emit(Events.RESUME, this.loop.pauseDuration);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue