mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Add runtime.getTargetById
helper
This commit is contained in:
parent
d4a43639f3
commit
23d9999a9f
1 changed files with 14 additions and 0 deletions
|
@ -260,6 +260,20 @@ Runtime.prototype.targetForThread = function (thread) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a target by its id.
|
||||||
|
* @param {string} targetId Id of target to find.
|
||||||
|
* @return {?Target} The target, if found.
|
||||||
|
*/
|
||||||
|
Runtime.prototype.getTargetById = function (targetId) {
|
||||||
|
for (var i = 0; i < this.targets.length; i++) {
|
||||||
|
var target = this.targets[i];
|
||||||
|
if (target.id == targetId) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an animation frame from the main thread.
|
* Handle an animation frame from the main thread.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue