Skip to content

Commit f81856a

Browse files
committed
Updated drag handlers.
1 parent 102fa3e commit f81856a

2 files changed

Lines changed: 13 additions & 25 deletions

File tree

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,15 @@ var SetDraggable = function (gameObjects, value)
1010
for (var i = 0; i < gameObjects.length; i++)
1111
{
1212
var gameObject = gameObjects[i];
13-
var index = this._draggable.indexOf(gameObject);
13+
var interactiveObject = gameObject.input;
1414

15-
if (value)
15+
if (interactiveObject)
1616
{
17-
// Make draggable
18-
gameObject.input.draggable = true;
19-
20-
if (index === -1)
21-
{
22-
this._draggable.push(gameObject);
23-
}
24-
}
25-
else
26-
{
27-
// Disable drag
28-
gameObject.input.draggable = false;
29-
30-
if (index === -1)
31-
{
32-
this._draggable.splice(index, 1);
33-
}
17+
interactiveObject.draggable = value;
3418
}
3519
}
3620

37-
return true;
21+
return this;
3822
};
3923

4024
module.exports = SetDraggable;

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ var DragStartEvent = new Class({
77

88
initialize:
99

10-
function DragStartEvent (pointer, gameObject)
10+
function DragStartEvent (pointer, topObject, gameObjects)
1111
{
1212
Event.call(this, 'DRAG_START_EVENT');
1313

1414
this.pointer = pointer;
15-
this.gameObject = gameObject;
16-
this.input = gameObject.input;
1715

18-
this.x = gameObject.input.localX;
19-
this.y = gameObject.input.localY;
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;
2024
}
2125

2226
});

0 commit comments

Comments
 (0)