new hat block for "when this scene starts"

snap7
jmoenig 2021-09-08 16:08:30 +02:00
rodzic 72d8000f57
commit 62647c8dee
5 zmienionych plików z 25 dodań i 15 usunięć

Wyświetl plik

@ -35,6 +35,7 @@
### 2021-09-08 ### 2021-09-08
* objects: changed category for "switch to scene" to control * objects: changed category for "switch to scene" to control
* blocks, objects, threads: new hat block for "when this scene starts"
### 2021-09-07 ### 2021-09-07
* blocks, objects, threads: new change-of-scene event * blocks, objects, threads: new change-of-scene event

Wyświetl plik

@ -16,8 +16,8 @@
<script src="src/morphic.js?version=2021-07-09"></script> <script src="src/morphic.js?version=2021-07-09"></script>
<script src="src/symbols.js?version=2021-03-03"></script> <script src="src/symbols.js?version=2021-03-03"></script>
<script src="src/widgets.js?version=2021-07-21"></script> <script src="src/widgets.js?version=2021-07-21"></script>
<script src="src/blocks.js?version=2021-09-07"></script> <script src="src/blocks.js?version=2021-09-08"></script>
<script src="src/threads.js?version=2021-09-07"></script> <script src="src/threads.js?version=2021-09-08"></script>
<script src="src/objects.js?version=2021-09-08"></script> <script src="src/objects.js?version=2021-09-08"></script>
<script src="src/scenes.js?version=2021-07-21"></script> <script src="src/scenes.js?version=2021-07-21"></script>
<script src="src/gui.js?version=2021-09-07"></script> <script src="src/gui.js?version=2021-09-07"></script>

Wyświetl plik

@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2021-September-07'; modules.blocks = '2021-September-08';
var SyntaxElementMorph; var SyntaxElementMorph;
var BlockMorph; var BlockMorph;
@ -416,8 +416,7 @@ SyntaxElementMorph.prototype.labelParts = {
'mouse-departed' : ['mouse-departed'], 'mouse-departed' : ['mouse-departed'],
'scrolled-up' : ['scrolled-up'], 'scrolled-up' : ['scrolled-up'],
'scrolled-down' : ['scrolled-down'], 'scrolled-down' : ['scrolled-down'],
'stopped' : ['stopped'], // experimental 'stopped' : ['stopped'] // experimental
'entering a scene' : ['entering a scene'] // experimental
} }
}, },
'%dates': { '%dates': {
@ -3158,6 +3157,8 @@ BlockMorph.prototype.showMessageUsers = function () {
message = '__shout__go__'; message = '__shout__go__';
} else if (this.selector === 'receiveOnClone') { } else if (this.selector === 'receiveOnClone') {
message = '__clone__init__'; message = '__clone__init__';
} else if (this.selector === 'receiveOnScene') {
message = '__scene__init__';
} else if (inputs[0] instanceof InputSlotMorph) { } else if (inputs[0] instanceof InputSlotMorph) {
message = inputs[0].evaluate(); message = inputs[0].evaluate();
} }

Wyświetl plik

@ -903,6 +903,11 @@ SpriteMorph.prototype.initBlocks = function () {
}, },
// Scenes // Scenes
receiveOnScene: {
type: 'hat',
category: 'control',
spec: 'when this scene starts'
},
doSwitchToScene: { doSwitchToScene: {
type: 'command', type: 'command',
category: 'control', category: 'control',
@ -2507,8 +2512,8 @@ SpriteMorph.prototype.blockTemplates = function (category = 'motion') {
blocks.push(block('receiveKey')); blocks.push(block('receiveKey'));
blocks.push(block('receiveInteraction')); blocks.push(block('receiveInteraction'));
blocks.push(block('receiveCondition')); blocks.push(block('receiveCondition'));
blocks.push(block('receiveMessage'));
blocks.push('-'); blocks.push('-');
blocks.push(block('receiveMessage'));
blocks.push(block('doBroadcast')); blocks.push(block('doBroadcast'));
blocks.push(block('doBroadcastAndWait')); blocks.push(block('doBroadcastAndWait'));
blocks.push(block('doSend')); blocks.push(block('doSend'));
@ -2547,9 +2552,10 @@ SpriteMorph.prototype.blockTemplates = function (category = 'motion') {
blocks.push(block('newClone')); blocks.push(block('newClone'));
blocks.push(block('removeClone')); blocks.push(block('removeClone'));
blocks.push('-'); blocks.push('-');
blocks.push(block('doPauseAll')); blocks.push(block('receiveOnScene'));
blocks.push('-');
blocks.push(block('doSwitchToScene')); blocks.push(block('doSwitchToScene'));
blocks.push('-');
blocks.push(block('doPauseAll'));
} else if (category === 'sensing') { } else if (category === 'sensing') {
@ -6092,6 +6098,9 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) {
if (morph.selector === 'receiveOnClone') { if (morph.selector === 'receiveOnClone') {
return message === '__clone__init__'; return message === '__clone__init__';
} }
if (morph.selector === 'receiveOnScene') {
return message === '__scene__init__';
}
} }
return false; return false;
}); });
@ -8438,9 +8447,7 @@ StageMorph.prototype.fireChangeOfSceneEvent = function () {
this.children.concat(this).forEach(morph => { this.children.concat(this).forEach(morph => {
if (isSnapObject(morph)) { if (isSnapObject(morph)) {
morph.allHatBlocksForInteraction( morph.allHatBlocksFor('__scene__init__').forEach(block =>
'entering a scene'
).forEach(block =>
procs.push(this.threads.startProcess( procs.push(this.threads.startProcess(
block, block,
morph, morph,
@ -8716,8 +8723,8 @@ StageMorph.prototype.blockTemplates = function (category = 'motion') {
blocks.push(block('receiveKey')); blocks.push(block('receiveKey'));
blocks.push(block('receiveInteraction')); blocks.push(block('receiveInteraction'));
blocks.push(block('receiveCondition')); blocks.push(block('receiveCondition'));
blocks.push(block('receiveMessage'));
blocks.push('-'); blocks.push('-');
blocks.push(block('receiveMessage'));
blocks.push(block('doBroadcast')); blocks.push(block('doBroadcast'));
blocks.push(block('doBroadcastAndWait')); blocks.push(block('doBroadcastAndWait'));
blocks.push(block('doSend')); blocks.push(block('doSend'));
@ -8754,9 +8761,10 @@ StageMorph.prototype.blockTemplates = function (category = 'motion') {
blocks.push(block('createClone')); blocks.push(block('createClone'));
blocks.push(block('newClone')); blocks.push(block('newClone'));
blocks.push('-'); blocks.push('-');
blocks.push(block('doPauseAll')); blocks.push(block('receiveOnScene'));
blocks.push('-');
blocks.push(block('doSwitchToScene')); blocks.push(block('doSwitchToScene'));
blocks.push('-');
blocks.push(block('doPauseAll'));
} else if (category === 'sensing') { } else if (category === 'sensing') {

Wyświetl plik

@ -64,7 +64,7 @@ SnapExtensions, AlignmentMorph, TextMorph, Cloud*/
/*jshint esversion: 6*/ /*jshint esversion: 6*/
modules.threads = '2021-September-07'; modules.threads = '2021-September-08';
var ThreadManager; var ThreadManager;
var Process; var Process;