kopia lustrzana https://github.com/backface/turtlestitch
added API: "switchTo"
rodzic
50e0242181
commit
72c3e87ad1
11
src/api.js
11
src/api.js
|
@ -39,7 +39,8 @@
|
|||
|
||||
*/
|
||||
|
||||
/*global modules, IDE_Morph, isString, Map, List, world, isNil, Project*/
|
||||
/*global modules, IDE_Morph, isString, Map, List, world, isNil, Project,
|
||||
detect*/
|
||||
|
||||
/*jshint esversion: 6*/
|
||||
|
||||
|
@ -78,6 +79,14 @@ IDE_Morph.prototype.getCurrentScene = function () {
|
|||
return this.scene.name;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.switchTo = function (sceneName) {
|
||||
var scene = detect(this.scenes.itemsArray(), scn => scn.name === sceneName);
|
||||
if (scene === null) {
|
||||
throw new Error('cannot find scene ' + sceneName);
|
||||
}
|
||||
this.switchToScene(scene);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.broadcast = function(message, callback) {
|
||||
// same as using the broadcast block - launch all scripts
|
||||
// in the current project reacting to the specified message,
|
||||
|
|
Ładowanie…
Reference in New Issue