zoukankan      html  css  js  c++  java
  • Breakable loop in Scratch

    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

  • 相关阅读:
    I'm Telling the Truth
    B-shaass and lights codeForces
    1
    不容易系列之(4)——考新郎 HDU
    犯人冲突
    不互质的和
    OI回忆录
    NOI2018退役记
    uoj221【NOI2016】循环之美
    uoj220【NOI2016】网格
  • 原文地址:https://www.cnblogs.com/lsgxeva/p/10452080.html
Copyright © 2011-2022 走看看