I spent a couple hours to create a first draft of a "spriteText" module, it takes a string and creates one sprite per character that will then only be drawn when they change.
This could be a really bad idea, but it works well and performance is good (half the fps drop of drawText). I'll happily share it when it has been trimmed and tested and optimised a little more.
It's for use on fixed length text strings whose contents change frequently, like:
- score
- lives
- timers
- hud text
It uses an image like your font .png (but not an actual font .png because imagetable won't load a .png that has an associated .fnt file, plus font .png files have characters that are not always in alphabetical/ascii order so there's that too. So I'm using a section of the font .png)
Currently it works like this:
spriteFont:createText(text, x,y)
- to create the sprites and set the initial positions
- optional: correct character widths using
playdate.graphics.font:getTextWidth(text)
- for outside of your loop
spriteFont:updateText(text, x,y)
- to update the sprites to represent the new/updated text and position
- for inside of your loop
Screenshot
fps ... spriteFont:drawText ... playdate.graphics.font:updateText