Skip to content

Commit 7142319

Browse files
committed
Removed un-used methods and properties
1 parent 094541d commit 7142319

1 file changed

Lines changed: 45 additions & 61 deletions

File tree

src/input/InputManager.js

Lines changed: 45 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,6 @@ var InputManager = new Class({
216216
*/
217217
this.activePointer = this.pointers[0];
218218

219-
/**
220-
* Reset every frame. Set to `true` if any of the Pointers are dirty this frame.
221-
*
222-
* @name Phaser.Input.InputManager#dirty
223-
* @type {boolean}
224-
* @since 3.10.0
225-
*/
226-
this.dirty = false;
227-
228219
/**
229220
* If the top-most Scene in the Scene List receives an input it will stop input from
230221
* propagating any lower down the scene list, i.e. if you have a UI Scene at the top
@@ -238,17 +229,6 @@ var InputManager = new Class({
238229
*/
239230
this.globalTopOnly = true;
240231

241-
/**
242-
* An internal flag that controls if the Input Manager will ignore or process native DOM events this frame.
243-
* Set via the InputPlugin.stopPropagation method.
244-
*
245-
* @name Phaser.Input.InputManager#ignoreEvents
246-
* @type {boolean}
247-
* @default false
248-
* @since 3.0.0
249-
this.ignoreEvents = -1;
250-
*/
251-
252232
/**
253233
* The time this Input Manager was last updated.
254234
* This value is populated by the Game Step each frame.
@@ -301,6 +281,16 @@ var InputManager = new Class({
301281
*/
302282
this._tempMatrix2 = new TransformMatrix();
303283

284+
/**
285+
* An internal private var that records Scenes aborting event processing.
286+
*
287+
* @name Phaser.Input.InputManager#_tempSkip
288+
* @type {boolean}
289+
* @private
290+
* @since 3.18.0
291+
*/
292+
this._tempSkip = false;
293+
304294
game.events.once(GameEvents.BOOT, this.boot, this);
305295
},
306296

@@ -321,9 +311,7 @@ var InputManager = new Class({
321311

322312
this.events.emit(Events.MANAGER_BOOT);
323313

324-
this.game.events.on(GameEvents.PRE_RENDER, this.preStep, this);
325-
326-
this.game.events.on(GameEvents.POST_RENDER, this.postRender, this);
314+
this.game.events.on(GameEvents.PRE_RENDER, this.preRender, this);
327315

328316
this.game.events.once(GameEvents.DESTROY, this.destroy, this);
329317
},
@@ -365,42 +353,30 @@ var InputManager = new Class({
365353
/**
366354
* Internal update, called automatically by the Game Step right at the start.
367355
*
368-
* @method Phaser.Input.InputManager#preStep
356+
* @method Phaser.Input.InputManager#preRender
369357
* @private
370-
* @since 3.16.2
358+
* @since 3.18.0
371359
*
372360
* @param {number} time - The time stamp value of this game step.
373361
*/
374-
preStep: function (time)
362+
preRender: function (time)
375363
{
376364
this.time = time;
377365

378366
this.events.emit(Events.MANAGER_UPDATE);
379367

380-
// this.ignoreEvents = false;
381-
},
382-
383-
/**
384-
* Internal update, called automatically by the Game Step right after everything has finished rendering.
385-
*
386-
* We do this because, in the life of a frame, rAF comes _after_ the input events. So, we need to clear down
387-
* the input settings, ready incase the new input events potentially change them prior to the next game step.
388-
*
389-
* https://medium.com/@paul_irish/requestanimationframe-scheduling-for-nerds-9c57f7438ef4
390-
*
391-
* @method Phaser.Input.InputManager#postRender
392-
* @private
393-
* @since 3.18.0
394-
*/
395-
postRender: function ()
396-
{
397-
// this.ignoreEvents = false;
368+
var scenes = this.game.scene.getScenes(true, true);
369+
var delta = this.game.loop.delta;
398370

399-
var pointers = this.pointers;
400-
401-
for (var i = 0; i < this.pointersTotal; i++)
371+
for (var i = 0; i < scenes.length; i++)
402372
{
403-
pointers[i].reset(this.game.getTime());
373+
var scene = scenes[i];
374+
375+
if (scene.sys.input && scene.sys.input.updatePoll(time, delta) && this.globalTopOnly)
376+
{
377+
// If the Scene returns true, it means it captured some input that no other Scene should get, so we bail out
378+
return;
379+
}
404380
}
405381
},
406382

@@ -705,18 +681,26 @@ var InputManager = new Class({
705681
* @param {number} time - The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now().
706682
* @param {number} delta - The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class.
707683
*/
708-
updateInputPlugins: function (time, delta)
684+
updateInputPlugins: function (type, time)
709685
{
710686
var scenes = this.game.scene.getScenes(true, true);
687+
var delta = this.game.loop.delta;
688+
689+
this._tempSkip = false;
711690

712691
for (var i = 0; i < scenes.length; i++)
713692
{
714693
var scene = scenes[i];
715694

716-
if (scene.sys.input && scene.sys.input.update(time, delta) && this.globalTopOnly)
695+
if (scene.sys.input)
717696
{
718-
// If the Scene returns true, it means it captured some input that no other Scene should get, so we bail out
719-
return;
697+
var capture = scene.sys.input.update(type, time, delta);
698+
699+
if ((capture && this.globalTopOnly) || this._tempSkip)
700+
{
701+
// If the Scene returns true, or called stopPropagation, it means it captured some input that no other Scene should get, so we bail out
702+
return;
703+
}
720704
}
721705
}
722706
},
@@ -739,7 +723,7 @@ var InputManager = new Class({
739723
pointer.updateMotion();
740724
});
741725

742-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
726+
this.updateInputPlugins(CONST.TOUCH_START, event.timeStamp);
743727
},
744728

745729
/**
@@ -760,7 +744,7 @@ var InputManager = new Class({
760744
pointer.updateMotion();
761745
});
762746

763-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
747+
this.updateInputPlugins(CONST.TOUCH_MOVE, event.timeStamp);
764748
},
765749

766750
/**
@@ -781,7 +765,7 @@ var InputManager = new Class({
781765
pointer.updateMotion();
782766
});
783767

784-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
768+
this.updateInputPlugins(CONST.TOUCH_END, event.timeStamp);
785769
},
786770

787771
/**
@@ -802,7 +786,7 @@ var InputManager = new Class({
802786
pointer.updateMotion();
803787
});
804788

805-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
789+
this.updateInputPlugins(CONST.TOUCH_CANCEL, event.timeStamp);
806790
},
807791

808792
/**
@@ -816,13 +800,11 @@ var InputManager = new Class({
816800
*/
817801
onMouseDown: function (event)
818802
{
819-
console.log(this.game.getFrame(), 'md', event.pageX, event.pageY);
820-
821803
this.mousePointer.down(event);
822804

823805
this.mousePointer.updateMotion();
824806

825-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
807+
this.updateInputPlugins(CONST.MOUSE_DOWN, event.timeStamp);
826808
},
827809

828810
/**
@@ -840,7 +822,7 @@ var InputManager = new Class({
840822

841823
this.mousePointer.updateMotion();
842824

843-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
825+
this.updateInputPlugins(CONST.MOUSE_MOVE, event.timeStamp);
844826
},
845827

846828
/**
@@ -858,7 +840,7 @@ var InputManager = new Class({
858840

859841
this.mousePointer.updateMotion();
860842

861-
this.updateInputPlugins(event.timeStamp, this.game.loop.delta);
843+
this.updateInputPlugins(CONST.MOUSE_UP, event.timeStamp);
862844
},
863845

864846
/**
@@ -1113,6 +1095,8 @@ var InputManager = new Class({
11131095
{
11141096
this.events.removeAllListeners();
11151097

1098+
this.game.events.off(GameEvents.PRE_RENDER);
1099+
11161100
if (this.keyboard)
11171101
{
11181102
this.keyboard.destroy();

0 commit comments

Comments
 (0)