"Wait until" implementation (#210)

This commit is contained in:
Tim Mickel 2016-09-22 17:00:38 -04:00 committed by GitHub
parent a118d50056
commit 2d736f2b87

View file

@ -19,6 +19,7 @@ Scratch3ControlBlocks.prototype.getPrimitives = function() {
'control_repeat_until': this.repeatUntil,
'control_forever': this.forever,
'control_wait': this.wait,
'control_wait_until': this.waitUntil,
'control_if': this.if,
'control_if_else': this.ifElse,
'control_stop': this.stop,
@ -76,6 +77,14 @@ Scratch3ControlBlocks.prototype.repeatUntil = function(args, util) {
}
};
Scratch3ControlBlocks.prototype.waitUntil = function(args, util) {
var condition = Cast.toBoolean(args.CONDITION);
// Only execute once per frame.
if (!condition) {
util.yieldFrame();
}
};
Scratch3ControlBlocks.prototype.forever = function(args, util) {
// Only execute once per frame.
// When the branch finishes, `forever` will be executed again and