Breakable loop in Scratch

https://stackoverflow.com/questions/30682144/breakable-loop-in-scratch

Breakable loop in Scratch ?

How do you make a breakable loop in Scratch? I'm using Scratch 2.0 and can't find any good way to make a loop breakable, from inside of the loop itself.

Disclaimer:

There is no perfect way to do it. If you can possibly stand this true fact then feel free to continue.


There are a few different ways you could do it.

With repeat until

The first and most simple one follows this:

But this isn't technically part of the script - it's just repeating until some value returns true.

With a custom block (stop this script)

In order to do it inside of the script, you'll need to use a sneaky little trick with custom blocks.

Create a custom block called whatever you want - but probably along the lines of "breakable loop". Inside of it, create this script:

By using stop script we are breaking out of the script that is currently running - which, according to Scratch, is the custom block.

See the result! (as scratchblocks)    http://scratchblocks.github.io

With broadcast and wait

You could also use a broadcast-and-wait method, very similar to above:

Though I highly suggest you don't use this method, as if any other sprites have breakable loops you'll need to rename each one, which can be tedious after using a lot of loops in a lot of sprites!

======================= End

Breakable loop in Scratch的更多相关文章

  1. intermediate-python-for-data-science

    目录 matplotlib plot Scatter Plot histogram Customization Dictionaries, Part 1 Create dictionary dicti ...

  2. 从Scratch到Python:会动的小猫

    大部分人提起儿童编程,就会想到Scratch,然而当儿童升入中学,学习什么语言比较合适呢?我认为,Python是未来的方向,为此我将会把一些经典的Scratch案例用Python重新实现,抛砖引玉,希 ...

  3. Atitit 解决Unhandled event loop exception错误的办法

    Atitit 解决Unhandled event loop exception错误的办法 查看workspace/.metadata/.log org.eclipse.swt.SWTError: No ...

  4. Looper.prepare()和Looper.loop()

    什么时候需要 Looper Looper用于封装了android线程中的消息循环,默认情况下一个线程是不存在消息循环(message loop)的,需要调用Looper.prepare()来给线程创建 ...

  5. PostgreSQL-PL/pgSQL-cursor,loop

    将spam_keyword表word字段的字符全部拆分,只是利用过程语言完成循环的操作而已. create or replace function proc1() returns setof text ...

  6. archlinux 加载loop模块,且设定loop设备个数

    如果loop模块没有编译进内核就要先加载loop模块 modprobe loop 然后更改/etc/modprobe.d/modprobe.conf(有些文章写是在/etc/modprobe.conf ...

  7. 工作邮件loop的用法

    examples come from native speaker Put john in the loop about this. He will have good advice. Why hav ...

  8. VMWare虚拟机实例拷贝到另一台服务器后出现Error in the RPC receive loop: RpcIn: Unable to send.错误的解决

    把一个VMWare虚拟机实例拷贝到另一台服务器后,在事件查看器中的应用程序日志中不断出现Error in the RPC receive loop: RpcIn: Unable to send.错误, ...

  9. 禁用nested loop join里的spool

    禁用nested loop join里的spool 转载自: https://blogs.msdn.microsoft.com/psssql/2015/12/15/spool-operator-and ...

随机推荐

  1. D2. Great Vova Wall (Version 2)

    l链接 [https://codeforces.com/contest/1092/problem/D2] 题意 和D1一样只是不能竖直放了 分析 水平放的话,就只可能是相邻等时才可以,而且你会发现 只 ...

  2. 如何在Anaconda中把python环境更新更高版本

    把Anaconda中的python从3.5.5更新到3.6版本,不想卸载重新安装.办法如下: 开始->Anaconda Promot 在Anaconda Promot中,输入: conda up ...

  3. NET 使用 RabbitMQ

    NET 使用 RabbitMQ 前言 最近项目要使用RabbitMQ,园里里面已经有很多优秀的文章,Rabbitmq官网也有.net实例.这里我尝试下图文并茂之形式记录下使用的过程. 安装 Rabbi ...

  4. [options] 未与 -source 1.6 一起设置引导类路径

    用ant与eclipse编译Cassandra 1.2.19,出现了“ [options] 未与 -source1.6一起设置引导类路径”的警告,并出现了一些编译错误,提示编译失败,上网找了很 多资料 ...

  5. 自定义threading.local

    1.threading相关. # Author:Jesi # Time : 2018/12/28 14:21 import threading import time from threading i ...

  6. ssh无密码登录多台机器,并让所有远程机执行相同命令

    问题集锦 其实标题的内容就是很常见的集群操作,当有一个脚本或者一个命令需要很多个机器同时(或者说接近同时)执行时,就涉及到几个问题: 怎么通知每个主机? 每个主机收到通知后,怎么让主机执行命令? 怎么 ...

  7. Python3练习题 035:Project Euler 007:第10001个素数

    import time def f(x): #判断 x 是否为素数,返回bool值 if x == 2: return True elif x <= 1: return False else: ...

  8. 【Python3练习题 014】 一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如6=1+2+3。编程找出1000以内的所有完数。

    a.b只要数字a能被数字b整除,不论b是不是质数,都算是a的因子.比如:8的质因子是 2, 2, 2,但8的因子就包括 1,2,4. import math   for i in range(2, 1 ...

  9. js原生实现div渐入渐出

    jq对渐入渐出进行封装,简单的使用连个方法就可以实现.fadeIn(),fadeOut();如果我们界面没有使用jq那么原生怎么实现呢? 我们讲解一下,这个原理.当我们要实现渐入的时候,首先是让隐藏的 ...

  10. 关于js的书写

    <li> <label>工号:</label> <input id="uidarr" type='text' onclick=" ...