mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-12 22:42:03 -04:00
Merge pull request #115 from tmickel/feature/2.0-loader
Start of a 2.0 project loader
This commit is contained in:
commit
86f136dd10
14 changed files with 2058 additions and 93 deletions
src/engine
|
@ -18,9 +18,8 @@ var defaultBlockPackages = {
|
|||
|
||||
/**
|
||||
* Manages targets, scripts, and the sequencer.
|
||||
* @param {!Array.<Target>} targets List of targets for this runtime.
|
||||
*/
|
||||
function Runtime (targets) {
|
||||
function Runtime () {
|
||||
// Bind event emitter
|
||||
EventEmitter.call(this);
|
||||
|
||||
|
@ -28,8 +27,9 @@ function Runtime (targets) {
|
|||
|
||||
/**
|
||||
* Target management and storage.
|
||||
* @type {Array.<!Target>}
|
||||
*/
|
||||
this.targets = targets;
|
||||
this.targets = [];
|
||||
|
||||
/**
|
||||
* A list of threads that are currently running in the VM.
|
||||
|
@ -418,6 +418,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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue