Stage, costumes, backdrops ()

* Add `Clone.prototype.getCostumeIndexByName`, keep in range

* Add basic costume primitives from Scratch 2.0

* Add costume getter block

* Add properties and methods for distinguishing stage and sprites-vs-clones

* Add backdrop-related looks blocks

* Fix up "switch to backdrop" to be working

* Costume/backdrop reporters are 1-indexed

* Fire "when backdrop switched" hats

* Cut cloning helpers for a separate PR

* Disable many blocks on the stage

* Refactor into _setCostumeOrBackdrop; implement switch backdrop and wait

* Fire hats even when backdrop unchanged
This commit is contained in:
Tim Mickel 2016-09-08 09:40:27 -04:00 committed by GitHub
parent 14feb64005
commit 797f844de3
5 changed files with 183 additions and 7 deletions
src/engine

View file

@ -434,6 +434,19 @@ Runtime.prototype.getTargetById = function (targetId) {
}
};
/**
* Get a target representing the Scratch stage, if one exists.
* @return {?Target} The target, if found.
*/
Runtime.prototype.getTargetForStage = function () {
for (var i = 0; i < this.targets.length; i++) {
var target = this.targets[i];
if (target.isStage) {
return target;
}
}
};
/**
* Handle an animation frame from the main thread.
*/