mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-21 18:59:55 -04:00
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:
parent
11e28111c5
commit
d0cd9cd897
3 changed files with 75 additions and 6 deletions
src/engine
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue