Skip to content

Commit 1cc79a3

Browse files
committed
Added onMove callback and event. Added processMove handler.
1 parent fdf257d commit 1cc79a3

11 files changed

Lines changed: 126 additions & 47 deletions

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '2ba7f500-6dc2-11e7-a19b-db1919761fe1'
2+
build: '5f8d0c50-6e14-11e7-a21a-f9e8835d9646'
33
};
44
module.exports = CHECKSUM;

v3/src/input/InteractiveObject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
2222

2323
callbackContext: gameObject,
2424

25+
dragX: 0,
26+
dragY: 0,
27+
28+
onMove: NOOP,
2529
onDown: NOOP,
2630
onUp: NOOP,
2731
onOver: NOOP,
2832
onOut: NOOP,
29-
30-
dragX: 0,
31-
dragY: 0,
32-
3333
onDragStart: NOOP,
3434
onDrag: NOOP,
3535
onDragEnd: NOOP

v3/src/input/local/SceneInputManager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var SceneInputManager = new Class({
5959
down: { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }
6060
};
6161

62-
this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut' ];
62+
this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove' ];
6363
},
6464

6565
// Add option to get all IOs within a Rect or Circle
@@ -90,6 +90,7 @@ var SceneInputManager = new Class({
9090
setOnOutCallback: require('./components/SetOnOutCallback'),
9191
setOnOverCallback: require('./components/SetOnOverCallback'),
9292
setOnUpCallback: require('./components/SetOnUpCallback'),
93+
setOnMoveCallback: require('./components/SetOnMoveCallback'),
9394

9495
processOverOutEvents: require('./components/ProcessOverOutEvents'),
9596
processDownEvents: require('./components/ProcessDownEvents'),
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var InputEvent = require('../events');
2+
3+
var ProcessMoveEvents = function (pointer, currentlyOver)
4+
{
5+
if (currentlyOver.length === 0)
6+
{
7+
// Dispatch MOVE event, even though pointer isn't over anything
8+
this.events.dispatch(new InputEvent.MOVE(pointer));
9+
}
10+
else
11+
{
12+
// Go through all objects the pointer is over and dispatch them
13+
for (var i = 0; i < currentlyOver.length; i++)
14+
{
15+
var interactiveObject = currentlyOver[i];
16+
17+
this.events.dispatch(new InputEvent.MOVE(pointer, interactiveObject.gameObject, currentlyOver));
18+
19+
this.childOnMove(pointer, interactiveObject);
20+
21+
if (this.topOnly)
22+
{
23+
break;
24+
}
25+
}
26+
}
27+
28+
// Check the list of Draggable Items
29+
/*
30+
for (var i = 0; i < this.children.draggable.length; i++)
31+
{
32+
var interactiveObject = this.children.draggable[i];
33+
34+
if (!interactiveObject.enabled)
35+
{
36+
continue;
37+
}
38+
39+
if (pointer.justUp && interactiveObject.isDragged)
40+
{
41+
// Drag End
42+
this.childOnDragEnd(i, pointer, interactiveObject);
43+
}
44+
else if (interactiveObject.isDragged)
45+
{
46+
// Drag
47+
this.childOnDrag(i, pointer, interactiveObject);
48+
}
49+
}
50+
*/
51+
52+
};
53+
54+
module.exports = ProcessMoveEvents;

v3/src/input/local/components/ProcessOverOutEvents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var ProcessOverOutEvents = function (pointer, currentlyOver)
2525
// In the currentlyOver array
2626
stillOver.push(interactiveObject);
2727
}
28-
};
28+
}
2929

3030
// Go through the hit test results
3131
for (i = 0; i < currentlyOver.length; i++)

v3/src/input/local/components/SetCallbacks.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
var SetCallbacks = function (gameObjects, onDown, onUp, onOver, onOut, context)
1+
var GetFastValue = require('../../../utils/object/GetFastValue');
2+
3+
var SetCallbacks = function (gameObjects, config)
24
{
5+
var onDown = GetFastValue(config, 'onDown', null);
6+
var onUp = GetFastValue(config, 'onUp', null);
7+
var onOver = GetFastValue(config, 'onOver', null);
8+
var onOut = GetFastValue(config, 'onOut', null);
9+
var onMove = GetFastValue(config, 'onMove', null);
10+
var context = GetFastValue(config, 'context', null);
11+
312
if (onDown)
413
{
514
this.setOnDownCallback(gameObjects, onDown, context);
@@ -20,6 +29,11 @@ var SetCallbacks = function (gameObjects, onDown, onUp, onOver, onOut, context)
2029
this.setOnDownCallback(gameObjects, onOut, context);
2130
}
2231

32+
if (onMove)
33+
{
34+
this.setOnMoveCallback(gameObjects, onMove, context);
35+
}
36+
2337
return this;
2438
};
2539

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var SetOnMoveCallback = function (gameObjects, callback, context)
2+
{
3+
return this.setCallback(gameObjects, 'onMove', callback, context);
4+
};
5+
6+
module.exports = SetOnMoveCallback;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ var Update = function (time, delta)
5656
this.processDownEvents(pointer, results);
5757
}
5858

59-
// if (pointer.justMoved)
60-
// {
61-
// this.processMovementEvents(pointer, results);
62-
// }
59+
if (pointer.justMoved)
60+
{
61+
this.processMoveEvents(pointer, results);
62+
}
6363
}
6464
};
6565

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var Class = require('../../../utils/Class');
2+
var Event = require('../../../events/Event');
3+
4+
var PointerMoveEvent = new Class({
5+
6+
Extends: Event,
7+
8+
initialize:
9+
10+
function PointerMoveEvent (pointer, topObject, gameObjects)
11+
{
12+
Event.call(this, 'POINTER_MOVE_EVENT');
13+
14+
this.pointer = pointer;
15+
16+
this.x = pointer.x;
17+
this.y = pointer.y;
18+
19+
// An array of all the game objects the pointer event occurred on
20+
this.list = gameObjects;
21+
22+
// A reference to the top-most game object in the list (based on display list order)
23+
this.gameObject = topObject;
24+
}
25+
26+
});
27+
28+
module.exports = PointerMoveEvent;

v3/src/input/local/events/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
DRAG: require('./DragEvent'),
77
DRAG_END: require('./DragEndEvent'),
88
DRAG_START: require('./DragStartEvent'),
9+
MOVE: require('./PointerMoveEvent'),
910
OUT: require('./PointerOutEvent'),
1011
OVER: require('./PointerOverEvent'),
1112
UP: require('./PointerUpEvent')

0 commit comments

Comments
 (0)