Skip to content

Commit 98f7559

Browse files
committed
Added Drop Event and handler for it.
1 parent b71972f commit 98f7559

7 files changed

Lines changed: 59 additions & 5 deletions

File tree

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: '3a5d2280-72ec-11e7-8b11-6305b5d0c265'
2+
build: 'ee28c910-72ef-11e7-8342-3d0a4b198ddc'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/zone/Zone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var Zone = new Class({
3838
this.setInteractive(shape, callback);
3939
}
4040

41-
this.input.dropzone = true;
41+
this.input.dropZone = true;
4242

4343
return this;
4444
},

v3/src/input/InteractiveObject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
1010

1111
enabled: true,
1212
draggable: false,
13-
dropzone: false,
13+
dropZone: false,
1414

1515
hitArea: hitArea,
1616
hitAreaCallback: hitAreaCallback,

v3/src/input/local/SceneInputManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var SceneInputManager = new Class({
6262
// pendingRemoval: Objects waiting to be removed from the list on the next call to 'begin'
6363
this._pendingRemoval = [];
6464

65-
// draggable: A list of all Game Objects that has been enabled for dragging
65+
// draggable: A list of all Game Objects that have been enabled for dragging
6666
this._draggable = [];
6767

6868
// drag: A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID
@@ -71,7 +71,7 @@ var SceneInputManager = new Class({
7171
// over: A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID
7272
this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] };
7373

74-
this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd' ];
74+
this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ];
7575
},
7676

7777
// Add option to get all IOs within a Rect or Circle

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ var ProcessDragEvents = function (pointer, time)
163163
input.dragX = input.localX - gameObject.displayOriginX;
164164
input.dragY = input.localY - gameObject.displayOriginY;
165165

166+
// Any drop zones here?
167+
for (var c = 0; c < currentlyOver.length; c++)
168+
{
169+
var overGameObject = currentlyOver[c];
170+
171+
if (overGameObject.input.dropZone)
172+
{
173+
this.events.dispatch(new InputEvent.DROP(pointer, gameObject, overGameObject));
174+
}
175+
}
176+
177+
// And finally the dragend event
178+
166179
this.events.dispatch(new InputEvent.DRAG_END(pointer, gameObject));
167180

168181
input.onDragEnd(gameObject, pointer, input.dragX, input.dragY);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var Class = require('../../../utils/Class');
2+
var Event = require('../../../events/Event');
3+
4+
var DropEvent = new Class({
5+
6+
Extends: Event,
7+
8+
initialize:
9+
10+
function DropEvent (pointer, gameObject, dropZone)
11+
{
12+
Event.call(this, 'DROP_EVENT');
13+
14+
// The Pointer that triggered the event
15+
this.pointer = pointer;
16+
17+
// The native DOM event (MouseEvent, TouchEvent, etc)
18+
this.event = pointer.event;
19+
20+
// The Game Object the event occurred on
21+
this.gameObject = gameObject;
22+
23+
// The drop zone the game object was dropped on
24+
this.dropZone = dropZone;
25+
26+
// The local x/y coordinates of the event within the Game Object
27+
// this.x = pointer.x;
28+
// this.y = pointer.y;
29+
30+
// this.dragX = gameObject.input.dragX;
31+
// this.dragY = gameObject.input.dragY;
32+
33+
// The local x/y coordinates of the event within the Game Object
34+
// this.dragX = pointer.x - gameObject.input.dragX;
35+
// this.dragY = pointer.y - gameObject.input.dragY;
36+
}
37+
38+
});
39+
40+
module.exports = DropEvent;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module.exports = {
44

5+
DROP: require('./DropEvent'),
56
DRAG: require('./DragEvent'),
67
DRAG_END: require('./DragEndEvent'),
78
DRAG_START: require('./DragStartEvent'),

0 commit comments

Comments
 (0)