Debugging - Breakpoints
CreatiCode last edited by
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.
To add a breakpoint, you just need to insert the following block at where you would like the project to pause:
You can add as many breakpoints to your project as you like, although usually only one or few of them are used.
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.
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.
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: