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. Appium+Python3+iOS定位元素

    前言: 最近在做IOS自动化测试,IOS的Appium环境都配置OK,执行起来真的慢,慢到怀疑人生,那么今天就来总结一下IOS定位方式和各个定位方式的速度排序. 据我观察,按查找元素的顺序速度,从快到 ...

  2. H5 video标签的第二种格式

    36-video标签的第二种格式 2.第二种格式存在的意义: 由于视频数据非常非常的重要, 所以五大浏览器厂商都不愿意支持别人的视频格式, 所以导致了没有一种视频格式是所有浏览器都支持的 这个时候W3 ...

  3. 用PhoneGap创建第一个项目

    1.在eclipse中新建Android Project2.在项目的目录下,建两个文件夹:/libs/assets/www3.进入将刚刚下载并解压的PhoneGap包里Anroid目录,我们需要的资源 ...

  4. Shell脚本1

    1Shell编程 Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言. Shell脚本 Shell 脚本(shell scr ...

  5. VO和DO转换(二) BeanUtils

    VO和DO转换(一) 工具汇总 VO和DO转换(二) BeanUtils VO和DO转换(三) Dozer VO和DO转换(四) MapStruct BeanUtils是Spring提供的,通常项目都 ...

  6. Mixing x86 with x64 code (混合编写x86和x64代码)

    几个月前我小小的研究了在WOW64下的32位进程中运行native x64代码. 第二个设想是在64位进程下运行x86代码.它们都是可以的,如我google的一样, 已经有人在使用这两种方法了: ht ...

  7. python基础之数据类型和数值类型

    python3的六大数据类型: 1.tuple元组 2.number数字 3.string字符串 4.set集合 5.list列表 6.dictionary字典 其中不可变数据3个:tuple.num ...

  8. anaconda + VSCode + 生产环境配置

    1. 修改jupyter notebook 默认路径: 进入anaconda 命令行, jupyter notebook --generate-config   生成配置文件, 该文件在    本机用 ...

  9. oracle创建表空间、创建用户、授权角色和导入导出用户数据

    使用数据库管理员身份登录 -- log as sysdba sqlplus / as sysdba; 创建临时表空间 -- create temporary tablespace create tem ...

  10. 使用withCount后再使用select设置查询的字段。就找不到withCount的数据了

    https://laravelacademy.org/index.php/discussion/1021 如:Article::withCount(['comments'])->select(' ...