IsoTextPrinter Class – Done

isotextprinter.png

I’ve implemented a general purpose isometric text printing class called IsoTextPrinter. Very simple, inelegant, a singleton with public data members, but easy to use and it works. It allows me to print arbitrary text in any colour, using any TrueType font in isometric projection, either down the X axis, or up the Z axis. There is even a default fallback print case that prints without projection. That might be useful too, perhaps for modeless text. This class is going to be very useful for all the floating scores and text I use for cubes.

The implementation is straightforward. IsoTextPrinter is a singleton state machine. The only passed in parameter is the string itself. Everything else, including the isometric coordinates, colours, alpha etc. can be set by updating the public members. The only members I’ve protected are the instance pointer for the singleton and the orientation, set via a function. No, I don’t know why I made that an exception either.

That was my first singleton. Was it good for you?

Funny, back in ’85, the only Singleton I’d ever heard of was Mike Singleton, the man famous for the seminal Lords of Midnight.

I really enjoyed coding this evening.

One hiccup – I pressed backspace a couple of times over an error and Xcode freaked out and deleted my IsoTextPrinter implementation file. It didn’t just remove it from the Sources organiser, it deleted it off the hard disk. Permanently. It wasn’t even in the trash. A panic Spotlight search revealed nothing. Thank God then, for Time Machine, which had a working version of the file from a few minutes earlier.

Tomorrow, some more XML.

Leave a Reply

Your email address will not be published. Required fields are marked *