Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    Debugging - Breakpoints

    Tools
    1
    1
    308
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

       

      Prerequisite

      • The Repeat Block

       

      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:

      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:
      dd9f96db-9c23-4783-a482-272ffd90b42f-image.png

      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.

       

      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:

      1 Reply Last reply Reply Quote 0
      • Pinned by  info-creaticode info-creaticode 
      • First post
        Last post