Microsoft MakeCode

"Text Sprite" extension

Hello world,

I’m working on an extension that makes it easier to have text in your game. The big motivations for me are for creating custom UI and HUD elements as well as signage in games. Using this extension, you can basically duplicate the built-in life, score and countdown elements.

These are the blocks:

and the expandable blocks expanded:
Screen Shot 2020-05-28 at 6.15.06 PM

This extension handles unicode. If non-ascii characters are entered, a unicode font will be used.
A maximum height for the text can be specified. Since our fonts in Arcade are limited, this will always be rounded down to a multiple of 5, 8, or 12. We try to use the most appropriate font for your size and whether or not unicode is present.

And of course since these are sprites all the other sprite functions work with these.

Here’s the extension:

Here’s a sample:


Future work:

  • What about word wrapping?
    • Likely answer: allow an optional “max width” and wrap appropriately

@darzu here is that word wrapping code I mentioned the other day. Looking at it now, it’s not complicated at all but at least I figured out the text ranges for punctuation!

1 Like

is there a way to update the text i real time?

Yes, the “set textSprite text (”")" block can be called as frequently as you like, perhaps in a “on game update” block if you want to report a frequently changing timer or score