Add methods for dragging and dropping sprites

* Add `getTargetIdForDrawableId` to translate between renderer picks and VM targets
* Add `startDrag` to stop sprite motion while dragging
* Add `stopDrag` to return sprite motion after dragging
This commit is contained in:
Ray Schamp 2017-03-03 09:35:57 -05:00
parent 11e28111c5
commit d0cd9cd897
3 changed files with 75 additions and 6 deletions
src/engine

View file

@ -793,6 +793,18 @@ Runtime.prototype.getSpriteTargetByName = function (spriteName) {
}
};
/**
* Get a target by its drawable id.
* @param {number} drawableID drawable id of target to find
* @return {?Target} The target, if found
*/
Runtime.prototype.getTargetByDrawableId = function (drawableID) {
for (var i = 0; i < this.targets.length; i++) {
var target = this.targets[i];
if (target.drawableID === drawableID) return target;
}
};
/**
* Update the clone counter to track how many clones are created.
* @param {number} changeAmount How many clones have been created/destroyed.