Fox Studios logo Fox StudiosGame projects, devlogs and Scratch builds
Tutorials

How to Make a Dialogue Box in Scratch for Your Game

We shipped a small Scratch adventure in March with four talking characters, and the first fifteen comments were all about the same thing. The speech bubbles were covering the people who were speaking.

A Scratch project showing a game character above a wide dialogue box at the bottom of the stage with text appearing letter by letter

We shipped a small Scratch adventure in March with four talking characters, and the first fifteen comments were all about the same thing. The speech bubbles were covering the people who were speaking. One player wrote that she had restarted twice because she thought the shopkeeper was broken, when really his bubble had drifted off the top of the stage and she never saw a word of it. The game was fine. The way it talked to her was not.

So we rebuilt the talking part, and the second version got a different kind of comment: people quoting lines back at us. That is the whole difference. A dialogue box you control is more work than a say block and it is the cheapest upgrade in perceived polish I know of in Scratch. Here is how we build one now, including the two bugs that cost us an evening each.

Why the say block runs out of road

The say block is genuinely good for a first project and I would never tell a beginner to skip it. Its limits only show up once you have more than a sentence to deliver.

A speech bubble anchors itself to the sprite, so it moves when the sprite moves and it reflows when the sprite is near an edge. You cannot set its width, its font, its colour or its position. Long text shrinks the font until it is unreadable on a phone, and Scratch wraps it wherever it likes. Worst of all, a say block with no duration does not wait for the player. Pair it with a wait block and the pacing is yours instead of the reader's, which is how you end up with testers pausing a video to read a line.

A dialogue box fixes all of that because it is just a sprite you drew, sitting at a fixed place with text drawn on top of it. No magic, roughly thirty blocks in total.

Building the box and the letters

The stage is 480 by 360 units. We put the box along the bottom at y equals 110 below centre, 440 wide and 90 tall, which leaves room for two lines of about 38 characters each at a comfortable size. Those numbers are worth copying because we arrived at them by testing on a school Chromebook where the stage was shown small.

  1. Draw the box. New sprite, paint a rounded rectangle 440 by 90 with a 4 unit border, set it to go to front layer, and name it Box. Give it a second costume with the border in a brighter colour for whichever character is speaking if you want that later.
  2. Make a Letters sprite. One costume per character you need: 26 lowercase, 26 uppercase, ten digits, and roughly twelve punctuation marks. Name each costume exactly the character it shows, so the costume for the letter k is named k. The costume name matters, because that is what you will switch to.
  3. Store the script in a list. Make a list called lines and add each sentence as its own item. We keep a second list called speakers with the matching character name in the same position, so item 7 of lines is spoken by item 7 of speakers.
  4. Write a Draw Letter custom block. It takes a character and an x position, switches the Letters sprite to that costume, goes to that x and the line's y, then stamps with the pen extension and hides again. Stamping rather than keeping a clone on screen is the detail that keeps the project fast.
  5. Loop across the sentence. Set a counter to 1, then repeat the length of the sentence: pull letter counter of the sentence, call Draw Letter with an x that advances by 11 units each time, change counter by 1. A space just advances x without stamping.
  6. Handle the second line. Before stamping, check whether x has passed the right edge. If the next character is a space, drop y by 30 and reset x to the left margin. Breaking on spaces rather than mid word is three extra blocks and it is the difference between a box that looks hand made and one that looks broken.
  7. Clear and advance. When the player presses the space key, erase all pen marks, move to the next item of lines, and run the loop again. When the list runs out, hide the Box sprite and broadcast that dialogue has finished so the rest of your game can resume.

If you have already built the list handling for something like our inventory system in Scratch, this will feel familiar, because it is the same idea pointed at words instead of items.

The typewriter timing that feels right

Revealing text one character at a time is the part players notice, and the speed is easy to get wrong in both directions. We tested four values with eleven people from our Discord, all reading the same 94 character line.

At a wait of 0.01 seconds per letter nobody could tell it was animating. At 0.03 seconds it read as deliberate and nine of eleven preferred it. At 0.06 seconds, which is where our first build sat, four people reached for the space key before the line finished and two said it felt like the game was slow. At 0.12 seconds everyone hated it. So 0.03 is our default now, and a 94 character line takes just under three seconds to appear.

Then give them a way out. If the player presses space while the text is still revealing, stop the loop and stamp the whole remaining sentence at once instead of advancing to the next line. Two presses should mean see it all, then move on, never skip a line unread. We got that backwards in the first build and a tester lost an entire quest explanation by tapping space twice out of habit.

The bug that cost us a whole evening lives right here. Scratch checks key presses every frame, so a plain wait until space pressed will fire again immediately on the next loop while the finger is still down, and the player blows through five lines in one tap. The fix is one extra block: wait until space pressed, then wait until space not pressed, before you continue. Anyone who has built a countdown timer in Scratch has met the same frame timing problem from the other direction.

What testers complained about after it worked

Getting the box working is maybe two hours. The feedback thread after we posted the update was more useful than the build itself, and three things came up that we had not thought about at all.

People wanted to know who was talking. Adding a small portrait costume at the left end of the box, 60 by 60, and the speaker's name stamped above the first line solved it in about twenty minutes. Several players also asked for the text to stay put rather than clear instantly, so now the box holds the final line until the next broadcast rather than erasing on the last press.

The one we argued about internally was a text speed setting. I thought it was clutter for a fifteen minute game. Two people on the thread pointed out that readers go at different speeds and that a fast and slow toggle is three blocks and a variable. They were right, and it went into the next build alongside the menu work from the tutorials section.

If you want one thing to do this week, build the Letters sprite. It is the boring half, maybe forty minutes of naming costumes, and once it exists in your backpack you can drop a working dialogue box into any future project in under half an hour. We have reused ours in four games now and it has never needed a rewrite.

FAQ

Do I need the pen extension for this?

Not strictly, but use it. The alternative is leaving a clone on screen for every character, and a two line box can reach 76 clones at once. Scratch caps clones at 300, so a few boxes in a row plus your other sprites can hit the ceiling and characters silently stop appearing. Stamping leaves zero clones behind.

How many letter costumes do I really need?

We use 74 and it covers everything our scripts contain. If you only write in lowercase with full stops and commas, 40 will do, and the loop can lowercase nothing on its own so you simply write your lines that way.

Is there an easier way with an extension?

On modified Scratch sites there are text extensions that draw a string in one block, and they work well. On the official site there is no such block, so a project built around one will not run where most of your players are. We stick to the costume method for anything we post publicly.

How do I store a long branching conversation?

Keep each branch as its own list and a variable holding which list is active, or encode the whole thing in one list where every item carries a prefix like a1 or b3 and your script jumps to the matching prefix. We used the second method for a 60 line conversation and it held up, though reading the list in the editor becomes unpleasant past about a hundred items.

DF
Diego Fenn

Diego covers finished builds and the community around them, and runs the feedback threads that shape what the studio makes next.

More posts by Diego

More in Tutorials

01doorganico 084goad 3hot8 4465456 after5internprogram ahandfulofblessings ahmadpc ahomcybersecurity allodialresources annodex antiquesandperiodcollectibles aotc asianworldkashmir beedlectrics bloggertemplatefree bluefeatheragency bodyweightsolution campaign08blog carfixadvisor catstreetcollective cbstvsports cnfanspurchasing committeeof500yearsofdignityandresistance covertopsdjs cs-kaiyuangame cuestacomunicaciontotal cxoutlet dancebetgame deskgearhub destinyvillastay detectmagazine di33 diamondsteelbuildings donmo dyanadropship emarsysfinance emimattl escapechan eskitarih evautoplay everythingweddings-orlando farmzone feedviewerapp gamevui123 gleasongrade greetingsday hacklabasu haskell iw-kaiyun jagoanproperti jilidskripsi joltbusinessfinance juegodepokergratis juegospucca kaeru-festival latestmehndidesigns lestanzediottaviano litemagazines localcommunityhero lustrsazan mariashebets menswheels newwebstechs1 nikkit ootheday oxigenvpn plurfitness prefetial probudgetcarpetcleaning psychicmrsmartin pyaten qvantor rejoignezlogis rexzbot riselayouts ruchin rwxqsgd5 sakaltime shibiaowang shop-bot skrtips spotlesshaven strcoding tetapatrium topselller uneplanteartificielle vipertechcr webtech1223411 wo-kygaming yamaha-mekar yeknava yoybuysheets zenunwa yamaha-mekar jilidskripsi ankertoto ankertoto ankertoto