Twinspire - an open source framework for 2D graphics in Kha

I have now added some more useful functionality to Twinspire, so instead of just updating the main post, I think it might be worth discussing new APIs that have been introduced.

Dimensions

The Dimensions class recently added to Twinspire Core is designed to assist in layout and performing logic on dimensions. Often, when working with anything relating to positions and sizes, there are trivial, if not boilerplate, code that needs performing when needing to layout your interface or other items on the screen.

This class attempts to solve trivial matters by providing useful utilities.

You can find a tutorial on this new API here.

Global Events

Event handling in Twinspire has been rethought. Instead of requiring you to manage your own event loop, the Core library handles all event routines for you, and if you ever need to query mouse positions, touch movements, gamepad buttons, etc., you just need to use the GlobalEvents class. Just remember to use GlobalEvents.end() at the end of each frame to prevent unwanted behaviour.

Resource Management

Resource management has been completely revamped.

Eventually, I will be working on using some form of compression tool to allow you to use “packed” resources and reading them as haxe.io.Bytes that can be read by the underlying code for ease of distribution and will be automatically handled by the new ResourceManager so you don’t have to implement extra logic.

Other Information

On a side note, as I work on an editor for a project I’ve been longing to make in an alternative language to C# (you guessed it, it’s Haxe), I will likely be working on a user interface library making extensive use of the above mentioned features. More on this later.

Thank you for reading.

1 Like