mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #817 from sjhuang26/develop
Fix ask-and-wait in stage
This commit is contained in:
commit
0722708004
1 changed files with 9 additions and 9 deletions
|
@ -63,9 +63,9 @@ class Scratch3SensingBlocks {
|
||||||
this._answer = answer;
|
this._answer = answer;
|
||||||
const questionObj = this._questionList.shift();
|
const questionObj = this._questionList.shift();
|
||||||
if (questionObj) {
|
if (questionObj) {
|
||||||
const [_question, resolve, target, wasVisible] = questionObj;
|
const [_question, resolve, target, wasVisible, wasStage] = questionObj;
|
||||||
// If the target was visible when asked, hide the say bubble.
|
// If the target was visible when asked, hide the say bubble unless the target was the stage.
|
||||||
if (wasVisible) {
|
if (wasVisible && !wasStage) {
|
||||||
this.runtime.emit('SAY', target, 'say', '');
|
this.runtime.emit('SAY', target, 'say', '');
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -73,16 +73,16 @@ class Scratch3SensingBlocks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_enqueueAsk (question, resolve, target, wasVisible) {
|
_enqueueAsk (question, resolve, target, wasVisible, wasStage) {
|
||||||
this._questionList.push([question, resolve, target, wasVisible]);
|
this._questionList.push([question, resolve, target, wasVisible, wasStage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_askNextQuestion () {
|
_askNextQuestion () {
|
||||||
if (this._questionList.length > 0) {
|
if (this._questionList.length > 0) {
|
||||||
const [question, _resolve, target, wasVisible] = this._questionList[0];
|
const [question, _resolve, target, wasVisible, wasStage] = this._questionList[0];
|
||||||
// If the target is visible, emit a blank question and use the
|
// If the target is visible, emit a blank question and use the
|
||||||
// say event to trigger a bubble.
|
// say event to trigger a bubble unless the target was the stage.
|
||||||
if (wasVisible) {
|
if (wasVisible && !wasStage) {
|
||||||
this.runtime.emit('SAY', target, 'say', question);
|
this.runtime.emit('SAY', target, 'say', question);
|
||||||
this.runtime.emit('QUESTION', '');
|
this.runtime.emit('QUESTION', '');
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,7 +100,7 @@ class Scratch3SensingBlocks {
|
||||||
const _target = util.target;
|
const _target = util.target;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const isQuestionAsked = this._questionList.length > 0;
|
const isQuestionAsked = this._questionList.length > 0;
|
||||||
this._enqueueAsk(args.QUESTION, resolve, _target, _target.visible);
|
this._enqueueAsk(args.QUESTION, resolve, _target, _target.visible, _target.isStage);
|
||||||
if (!isQuestionAsked) {
|
if (!isQuestionAsked) {
|
||||||
this._askNextQuestion();
|
this._askNextQuestion();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue