Execution of separate blocks

665 views
Skip to first unread message

Руслан И.

unread,
Sep 15, 2018, 6:33:16 AM9/15/18
to Blockly
Hello! In blockly games, code is executed even if blocks are not connected with each other. 
So I have two questions:
1) Is there a way to check if there are unconnected blocks on workspace?
2) Is there a way to execute only upper most block on workspace and ignore the others?

Снимок.PNG


Neil Fraser

unread,
Sep 15, 2018, 11:21:22 PM9/15/18
to blo...@googlegroups.com
Yes, if your program has a 'start' block of some sort, then you can add this line of code:
workspace.addChangeListener(Blockly.Events.disableOrphans);

Here is an example:

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Руслан И.

unread,
Sep 17, 2018, 6:57:49 AM9/17/18
to Blockly
Thank you! This was really helpful! 
By the way, can you please answer one more question: How to make start block look like "header that sit on top of a stack of blocks." ?

Erik Pasternak

unread,
Sep 17, 2018, 12:49:31 PM9/17/18
to Blockly

Blockly.BlockSvg.START_HAT = true;

More details on this page of the docs.

Cheers,
Erik
Message has been deleted
Message has been deleted

Руслан И.

unread,
Sep 18, 2018, 2:07:18 AM9/18/18
to Blockly
I've enabled START_HAT like you said.
Is it possible to change the look of start block from this :

1.pnginto this:2.png

Erik Pasternak

unread,
Sep 18, 2018, 10:58:44 AM9/18/18
to Blockly
You can get the appearance of the second by using a next connection instead of a statement input, but the code generation won't wrap it like a function. https://github.com/google/blockly/issues/384 is tracking having the bottom rendering with generator support for wrapping it.
Reply all
Reply to author
Forward
0 new messages