mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 14:40:38 +00:00
Updated drag handlers.
This commit is contained in:
parent
102fa3e5d1
commit
f81856a75c
2 changed files with 13 additions and 25 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue