Something a bit different for the 11th instalment in my corona samples series – XML parsing. I’ve turned my focus onto developing a game lately, and have been playing around with the Lime engine. There are some aspects of it I’m not happy with, so began rewriting it. One part (which isn’t really part of Lime) is the XML parsing. When it loads a .tmx file, it parses the lot in one hit. It’s not too slow, but there is a noticeable pause when loading, parsing and then generating the level. I’m building a new engine, based off Lime, that will allow asynchronous loading and level generation – meaning it’s possible to have a loading bar, animation, audio, etc going at the same time.
This sample shows off the xml parser I will be using in the engine. The original parsing code was written by Alexander Makeev (can be downloaded [here]). I used this as a base (and also included it in the demo – see xmlparser.lua)
The sample has a rotating cube, that will continue to rotate as the xml is parsed. You can increase or decrease the parsing rate by modifying the parseRate variable. Increasing this will lower framerate but complete the task quicker, decreasing will lower the effect on the framerate and take longer.
There is room for optimising, but it’s not too bad for loading a level map on the fly, while the rest of the game is currently running.
You can download the source here: [Download]