This has been another one of those tasks I’d been putting off for a long time. The main app framework, options menu, instructions, etc etc.
I already had a set of classes that handled all this stuff, including a menu, instructions, highscores, about pages and a bunch of other functionality but it was incredibly bloated and old. In fact, looking back at the original file I see I created the first version in 2003 so that’s 13 years ago! It’s been ported from JavaME and had all sorts of cruft in there to deal with the idiosyncrasies of ancient mobile phones plus maintaining backwards compatibility with titles that will (thankfully) never see the light of day again. It’s served me well but it was time to start again (more or less) from scratch – even though I knew that was to be a fairly painful process.
So I kept some classes that were written comparatively recently and were relatively bloat-free (the actual menu itself and the highscore management stuff) and got rid of everything else, adding the necessary code back in a piece at a time, refactoring it, and going through every line to trim all the bloat. It took me over a day just to get the thing to compile!
A part of the process I also streamlined all the graphics scaling to work with pixel-art games (where everything is drawn from one set of graphics rather than loading in a separate set for different screen-sizes) and improved some of the visual UI feedback, animations and tweening. There may be a bit too much ‘bounce’ in some of the tweens, I’m using an ‘exponentially decaying parabolic bounce’ tweening algorithm that is all over the web but I can’t find anything to specify the ‘amount’ of the bounce and the maths is a bit over my head. I will try and get my head around it at a later date.
And now I have a streamlined, bloat-free ‘main app’ class that manages the main menu, highscores and instructions. There is still some functionality I need to add (and some that has moved to new classes) but I have ditched almost 4000 lines of confusing and redundant code which is a good feeling.
One aspect that I spent a fair bit of time on was the formatting of the instructions pages. I wanted a system that would be very easy to edit, reuse, and apply to other elements of the app (such as about screens etc) so created generic InAppDoc and InAppDocViewer classes. An InAppDoc is created from an XML document which defines various elements such as pages and paragraphs of text but can also have custom elements that can be rendered by a specific game (such as individual sprites or sprite groups). It should be straightforward to extend this system to cope with localisations or even to add custom tags for more complex page layouts etc. An example of the XML used to create the series of test pages on the right is here. I need to fix those flashing arrows!
Dev Time: 7 days
Total Dev Time: approx 91.5 days

The Tweaked Main Menu With Added ‘Bounce’

Some Placeholder Instructions Pages To Test The InAppDoc classes