Adding an outline around your sprite in Scratch is one of those small details that can completely transform the look of your project. Outlines make characters pop off the screen, look cleaner against different backgrounds, and give your game a more polished look.
In this tutorial, we’ll walk through how to code a dynamic outline effect in Scratch using the Pen extension and a custom block.
I’ve tried a lot of other outline tricks in Scratch, but most of them fall apart once your sprite starts moving, rotating, or changing size. This method, on the other hand, keeps the outline smooth and perfect no matter what your sprite is doing.
Watch the full tutorial on YouTube here:
Let’s go through the process step by step.
Go to the bottom left corner of Scratch, choose Extensions,
and add the Pen extension.
Like every Scratch project, begin with:
and then
This ensures your sprite always starts in the center.
We’ll create a custom block called DrawOutline. Add three inputs:
Check “Run without screen refresh” so it executes instantly.
Use:
This turns the sprite black so it can act as the outline. Don’t worry, we’ll reset it later.
Here’s the logic:
Move the sprite slightly left
Stamp it
Repeat this for positions: left, center, and right
At each x-position, loop over y-values: bottom, middle, top
Stamp once at each position
This creates a 3×3 grid of stamps around the original sprite, giving the appearance of an outline.
After stamping:
This returns the sprite to its original position and color.
All together our custom block should be like this:
Under the When Green Flag Clicked block:
This is just one example of how the Pen extension can add polish to your projects. Next, you can try:
Test your knowledge with this short quiz!
Question 1: You want your Scratch sprite to have a clean outline that stays aligned even when it rotates or changes size. Which approach works best?
A) Simply change the sprite’s costume color to black
B) Use the Pen extension to stamp the sprite around its position with a custom block
C) Draw the outline by changing the size and stamping the sprite
D) Use the “Change Brightness” effect every frame
Answer: B) Use the Pen extension. This allows the outline to stay smooth and aligned even when the sprite moves, rotates, or changes size.
Question 2: Why is it important to use the "erase all" block at the beginning of the code?
A) To change the sprite's color
B) To make the sprite invisible
C) To move the sprite
D) To clear old outlines
Answer: D) To clear old outlines, otherwise, the screen would get cluttered with overlapping stamps from previous runs.
Question 3: Why do we use a custom block called DrawOutline instead of placing the stamp code directly in the main script?
A) To make the code reusable and organized
B) To make the sprite jump automatically
C) To change the sprite color permanently
D) To slow down the program
Answer: A) To make the code reusable and organized. The custom block can be called multiple times for different sprites or repeated actions.
Subscribe to our YouTube channel for more Scratch tutorials that make programming fun and easy to follow.