mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-10 21:39:57 -04:00
Merge pull request #1631 from mzgoddard/stop-other-asks
Stop other asks
This commit is contained in:
commit
23f6346045
3 changed files with 112 additions and 0 deletions
src/engine
|
@ -383,6 +383,15 @@ class Runtime extends EventEmitter {
|
|||
return 'PROJECT_STOP_ALL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for target being stopped by a stop for target call.
|
||||
* Used by blocks that need to stop individual targets.
|
||||
* @const {string}
|
||||
*/
|
||||
static get STOP_FOR_TARGET () {
|
||||
return 'STOP_FOR_TARGET';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for visual value report.
|
||||
* @const {string}
|
||||
|
@ -1450,6 +1459,9 @@ class Runtime extends EventEmitter {
|
|||
* @param {Thread=} optThreadException Optional thread to skip.
|
||||
*/
|
||||
stopForTarget (target, optThreadException) {
|
||||
// Emit stop event to allow blocks to clean up any state.
|
||||
this.emit(Runtime.STOP_FOR_TARGET, target, optThreadException);
|
||||
|
||||
// Stop any threads on the target.
|
||||
for (let i = 0; i < this.threads.length; i++) {
|
||||
if (this.threads[i] === optThreadException) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue