Time for action - wait until button not pressed

Did you come up with a way to fix our slideshow so that it advances only one screen at a time when we click the button? We're going to modify the forever if conditional statement to wait until the button is not pressed before continuing.

Read on for the details, but I'd love to hear other solutions, if you came up with any:

  1. From the Control palette, add a wait until block to the broadcast next block.
  2. From the Operators palette, add a not block to the wait until block.
  3. From the Sensing palette, add a sensor block to the not block. Select the button pressed value.
  4. Click the flag to reset the show. Click the button to navigate the show.
Time for action - wait until button not pressed

Now, that's much better. One click equals one slide.

What just happened?

To fully appreciate what just happened, let's quickly recap what we know about the forever if block. When the flag is clicked, the script constantly checks to see if the condition is met. The forever if block stops checking only when we stop the program.

In our project, the sensor value is continually evaluated. When the button pressed value equals true, the code broadcasts a message to flip to the next slide. And before the script continues, the code waits until the button pressed value equals false.

By waiting until the button was not pressed at the end of the forever if block, we made Scratch interpret the sensor in the way we intended: One human button click advanced the show by one slide.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.189