Updated drag handlers.

This commit is contained in:
photonstorm 2017-07-24 14:10:42 +01:00
parent 102fa3e5d1
commit f81856a75c
2 changed files with 13 additions and 25 deletions

View file

@ -10,31 +10,15 @@ var SetDraggable = function (gameObjects, value)
for (var i = 0; i < gameObjects.length; i++)
{
var gameObject = gameObjects[i];
var index = this._draggable.indexOf(gameObject);
var interactiveObject = gameObject.input;
if (value)
if (interactiveObject)
{
// Make draggable
gameObject.input.draggable = true;
if (index === -1)
{
this._draggable.push(gameObject);
}
}
else
{
// Disable drag
gameObject.input.draggable = false;
if (index === -1)
{
this._draggable.splice(index, 1);
}
interactiveObject.draggable = value;
}
}
return true;
return this;
};
module.exports = SetDraggable;

View file

@ -7,16 +7,20 @@ var DragStartEvent = new Class({
initialize:
function DragStartEvent (pointer, gameObject)
function DragStartEvent (pointer, topObject, gameObjects)
{
Event.call(this, 'DRAG_START_EVENT');
this.pointer = pointer;
this.gameObject = gameObject;
this.input = gameObject.input;
this.x = gameObject.input.localX;
this.y = gameObject.input.localY;
this.x = pointer.x;
this.y = pointer.y;
// An array of all the game objects the pointer event occurred on
this.list = gameObjects;
// A reference to the top-most game object in the list (based on display list order)
this.gameObject = topObject;
}
});