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. Django 中的 cookie 和 session

    一.cookie 由于HTTP协议是无状态的,而服务器端的业务必须是要有状态的.Cookie诞生的最初目的是为了存储web中的状态信息,以方便服务器端使用.比如判断用户是否是第一次访问网站.目前最新的 ...

  2. 《梦断代码》Scott Rosenberg著(三)

    开放与封闭之论: 程序源代码是商业软件公司最重要的资产,所以软件公司售卖二进制文件.这样也就意味着如果微软的软件产品出了问题,即便你是一个程序大牛也无法修复它.你只能等着微软来修正问题,因为只有微软程 ...

  3. 合并dll文件

    在使用VS进行.Net编程时,出现了一个奇怪的现象. 在一个类库项目中导入了dll库A后,再导入A的两个依赖项(dll库)B和C,执行“生成”操作时,出现错误信息,提示B和C的库版本与A所需的不一致. ...

  4. MySQL根据某个字段查询重复的数据

    select count(*) '个数',mobile '手机号',`name` '用户名' from users group by mobile having(count(*) > 1); = ...

  5. Java 基本数据类型 及 == 与 equals 方法的区别

    Java数据类型分为基本数据类型与引用数据类型. 1 基本数据类型 byte:Java中最小的数据类型,在内存中占1个字节(8 bit),取值范围-128~127,默认值0 short:短整型,2个字 ...

  6. day 7-11 初识MySQL数据库及安装密码设置破解

    一. 什么是数据库 之前所学,数据要永久保存,比如用户注册的用户信息,都是保存于文件中,而文件只能存在于某一台机器上. 如果我们不考虑从文件中读取数据的效率问题,并且假设我们的程序所有的组件都运行在一 ...

  7. git修改用户名、邮箱

    在windows使用git命令方法如下(以win7为例):1.msysgit 是 Windows 版的 Git可以百度搜索Git下载.2.安装完成后,开始菜单里找到“Git”->“Git Bas ...

  8. Spark 数据倾斜

    Spark 数据倾斜解决方案 2017年03月29日 17:09:58 阅读数:382 现象       当你的应用程序发生以下情况时你该考虑下数据倾斜的问题了: 绝大多数task都可以愉快的执行,总 ...

  9. Sqoop 使用详解(内含对官方文档的解析)

    Sqoop 是 Cloudera 公司创造的一个数据同步工具,现在已经完全开源了. 目前已经是 hadoop 生态环境中数据迁移的首选,另外还有 ali 开发的 DataX 属于同类型工具,由于社区的 ...

  10. Python:matplotlib绘制线条图

    线型图是学习matplotlib绘图的最基础案例.我们来看看具体过程:  下面我们将两条曲线绘制到一个图形里:   可以看到这种方式下,两个线条共用一个坐标轴,并且自动区分颜色. plot方法的核心是 ...