Skip to content

Commit 7f91956

Browse files
committed
Added time property and preStep.
1 parent f0de619 commit 7f91956

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

src/input/InputManager.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,17 @@ var InputManager = new Class({
356356
*/
357357
this.useQueue = config.inputQueue;
358358

359+
/**
360+
* The time this Input Manager was last updated.
361+
* This value is populated by the Game Step each frame.
362+
*
363+
* @name Phaser.Input.InputManager#time
364+
* @type {number}
365+
* @readonly
366+
* @since 3.16.2
367+
*/
368+
this.time = 0;
369+
359370
/**
360371
* Internal property that tracks frame event state.
361372
*
@@ -431,6 +442,10 @@ var InputManager = new Class({
431442
{
432443
this.game.events.on(GameEvents.PRE_STEP, this.legacyUpdate, this);
433444
}
445+
else
446+
{
447+
this.game.events.on(GameEvents.PRE_STEP, this.preStep, this);
448+
}
434449

435450
this.game.events.on(GameEvents.POST_STEP, this.postUpdate, this);
436451

@@ -469,8 +484,6 @@ var InputManager = new Class({
469484
this._emitIsOverEvent = event;
470485
},
471486

472-
473-
474487
/**
475488
* Internal update method, called automatically when a DOM input event is received.
476489
*
@@ -504,6 +517,20 @@ var InputManager = new Class({
504517
}
505518
},
506519

520+
/**
521+
* Internal update, called automatically by the Game Step.
522+
*
523+
* @method Phaser.Input.InputManager#preStep
524+
* @private
525+
* @since 3.16.2
526+
*
527+
* @param {number} time - The time stamp value of this game step.
528+
*/
529+
preStep: function (time)
530+
{
531+
this.time = time;
532+
},
533+
507534
/**
508535
* Internal update loop, called automatically by the Game Step when using the legacy event queue.
509536
*
@@ -516,6 +543,8 @@ var InputManager = new Class({
516543
*/
517544
legacyUpdate: function (time)
518545
{
546+
this.time = time;
547+
519548
var i;
520549

521550
this._setCursor = 0;

0 commit comments

Comments
 (0)