Debugging - Breakpoints
-
Prerequisite
What’s a “Breakpoint”
A “breakpoint” is where the program can “take a break”. That is, it will pause for a moment, and continue when you ask it to. While it is paused, you can do many things to check if your project is working as expected, such as checking the value of variables, the position of sprites, etc.
The “Breakpoint” Block
To add a breakpoint, you just need to insert the following block at where you would like the project to pause:
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/57ae89aa-a07c-4b74-90fe-ee8961b2b9ec.png" width="120" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">
You can add as many breakpoints to your project as you like, although usually only one or few of them are used.
The “Debug” Button
When you run a program using the green flag button, all breakpoints are ignored. To activate them, you need to run the program in the “Debug Mode” by clicking the blue arrow button:

In the debug mode, the program will pause whenever it arrives at a breakpoint. To continue the program from the breakpoint, you just need to click the blue arrow button again.
Example 1
In this example, we have 2 breakpoints, so the program will pause on the first breakpoint after completing all blocks before it. When we click the blue arrow button again, the program continues until the second breakpoint.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/41f8c075-bfb6-48d0-8301-265390496fbe.gif" width="600" style="border-radius: 5px; border: 1px solid #29622d;">
Example 2
You can also place the breakpoint inside an “if” block, so that it will only pause the program when a certain condition is met.
In this example, we will keep moving the dog to the bottom, and only pause the loop when the dog is touching the apple sprite:
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/bdf54d3f-a691-4d7e-baac-daed11351a18.gif" width="600" style="border-radius: 5px; border: 1px solid #29622d;">
-
I CreatiCode pinned this topic on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login