Skip to content

Commit f0ea5bf

Browse files
committed
Tidying up the global input manager.
1 parent e459729 commit f0ea5bf

8 files changed

Lines changed: 31 additions & 152 deletions

v3/src/input/global/GlobalInputManager.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
var Class = require('../../utils/Class');
44
var EventDispatcher = require('../../events/EventDispatcher');
55
var Gamepad = require('../gamepad/GamepadManager');
6-
var GetTransformedPoint = require('./inc/GetTransformedPoint');
76
var HitTest = require('./inc/HitTest');
87
var Keyboard = require('../keyboard/KeyboardManager');
98
var Mouse = require('../mouse/MouseManager');
109
var MouseEvent = require('../mouse/events/');
1110
var Pointer = require('../Pointer');
12-
var PointScreenToWorldHitTest = require('./inc/PointScreenToWorldHitTest');
13-
var PointWithinGameObject = require('./inc/PointWithinGameObject');
1411
var Touch = require('../touch/TouchManager');
15-
var TransformMatrix = require('../../gameobjects/components/TransformMatrix');
1612

1713
var GlobalInputManager = new Class({
1814

@@ -45,7 +41,7 @@ var GlobalInputManager = new Class({
4541

4642
this.bounds;
4743

48-
this._tempMatrix = new TransformMatrix();
44+
// this._tempMatrix = new TransformMatrix();
4945
this._tempPoint = { x: 0, y: 0 };
5046
this._tempHitTest = [];
5147
},
@@ -159,26 +155,12 @@ var GlobalInputManager = new Class({
159155
}
160156
},
161157

162-
getTransformedPoint: function (gameObject, x, y)
163-
{
164-
return GetTransformedPoint(this._tempMatrix, gameObject, x, y, this._tempPoint);
165-
},
166-
167-
pointWithinGameObject: function (gameObject, x, y)
168-
{
169-
return PointWithinGameObject(gameObject, x, y);
170-
},
171-
172158
hitTest: function (gameObjects, x, y, camera)
173159
{
174-
return HitTest(this._tempMatrix, x, y, gameObjects, camera, this._tempHitTest);
175-
},
176-
177-
pointScreenToWorldHitTest: function (gameObjects, x, y, camera)
178-
{
179-
return PointScreenToWorldHitTest(this._tempMatrix, x, y, gameObjects, camera, this._tempHitTest);
160+
return HitTest(this._tempPoint, x, y, gameObjects, camera, this._tempHitTest);
180161
},
181162

163+
// Called by Pointer class
182164
transformX: function (pageX)
183165
{
184166
return (pageX - this.bounds.left) * this.scale.x;

v3/src/input/global/inc/GetTransformedPoint.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

v3/src/input/global/inc/PointScreenToWorldHitTest.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

v3/src/input/global/inc/PointWithinGameObject.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

v3/src/input/global/inc/PointWithinHitArea.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
// x/y MUST be translated before being passed to this function,
22
// unless the gameObject is guaranteed to not be rotated or scaled in any way
33

4-
var PointWithinHitArea = function (gameObject, x, y, camera)
4+
var PointWithinHitArea = function (gameObject, x, y)
55
{
66
var input = gameObject.input;
77

8-
// if (!input)
9-
// {
10-
// return false;
11-
// }
12-
138
// Normalize the origin
149
x += gameObject.displayOriginX;
1510
y += gameObject.displayOriginY;

v3/src/input/global/inc/PointWithinInteractiveObject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// x/y MUST be translated before being passed to this function, unless the gameObject is guarnateed to
1+
// x/y MUST be translated before being passed to this function, unless the gameObject is guaranteed to
22
// be not rotated or scaled in any way
33

44
var PointWithinInteractiveObject = function (object, x, y)

v3/src/input/local/inc/HitTestPointer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Called from SceneInputManager.update
2+
13
var HitTestPointer = function (pointer)
24
{
35
var camera = this.cameras.getCameraBelowPointer(pointer);

v3/src/input/local/inc/Update.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,38 @@ var Update = function (time, delta)
1717
}
1818
}
1919

20-
if (runUpdate)
20+
if (!runUpdate)
2121
{
22-
this._temp = this.hitTestPointer(pointer);
22+
return;
23+
}
2324

24-
this.sortGameObjects(this._temp);
25+
this._temp = this.hitTestPointer(pointer);
2526

26-
if (this.topOnly && this._temp.length)
27-
{
28-
// Only the top-most one counts now, so safely ignore the rest
29-
this._temp.splice(1);
30-
}
27+
this.sortGameObjects(this._temp);
3128

32-
this.processDragEvents(pointer, time);
29+
if (this.topOnly && this._temp.length)
30+
{
31+
// Only the top-most one counts now, so safely ignore the rest
32+
this._temp.splice(1);
33+
}
3334

34-
this.processOverOutEvents(pointer);
35+
this.processDragEvents(pointer, time);
3536

36-
if (pointer.justDown)
37-
{
38-
this.processDownEvents(pointer);
39-
}
37+
this.processOverOutEvents(pointer);
4038

41-
if (pointer.justUp)
42-
{
43-
this.processUpEvents(pointer);
44-
}
39+
if (pointer.justDown)
40+
{
41+
this.processDownEvents(pointer);
42+
}
4543

46-
if (pointer.justMoved)
47-
{
48-
this.processMoveEvents(pointer);
49-
}
44+
if (pointer.justUp)
45+
{
46+
this.processUpEvents(pointer);
47+
}
48+
49+
if (pointer.justMoved)
50+
{
51+
this.processMoveEvents(pointer);
5052
}
5153
};
5254

0 commit comments

Comments
 (0)