Tag Archives: Lua

Bitmap Fonts in Corona SDK

Using your own, custom fonts in games and apps is essential to create the right GUI. Sometimes this can be done with a standard font asset drawn natively; however this doesn’t always provide you with enough artistic licence to create what you really need, and in some cases, ie Windows Phone, using native fonts has a huge impact on performance. There is a solution. Bitmap fonts. Although the idea of bitmaps fonts isn’t new, in fact its very old; using them in you Corona projects can typically be a pain. Many years ago, someone wrote bmf.lua, which worked a treat to draw your bitmap fonts onto your scene, however it had a few shortfalls. Corona SDK then released graphics 2.0, which broke bmf.lua completely.

The following article will walk you through my workflow for producing and using bitmap fonts in corona; including a version of bmf.lua that I have updated for the following functions:

  • Corona Graphics 2.0 Compatible
  • Corona SDK image map format compatible
  • .fnt definition file compatible
  • Read the drawn width and height at run-time
  • Re-size the font at run-time, without having to destroy and reinitialize.

Continue reading

Coding background image

Authenticating Saved Data in Apps

Cheating is becoming a bigger and bigger problem for developers. You only have to look at the leader boards for the ‘Flappy Bird’ game and you will find hundreds of users on 999999. It’s near impossible to actually achieve that in the game, but users can easily access the files used to save this data and modify it to meet their needs.

It’s not only high scores that are an issue. Developers need a way of keeping track of in-app purchases, and this is often saved on the device in the form of JSON or SQL files. This obviously opens the door up to users activating features or items without paying for them.

There is however, a simple solution to check if the data being saved, then loaded back into the app is genuine or not. This is in the form of a checksum. A simple calculation using the data you want to save, a random key, and the resultant. Simply calculate a checksum at data save and store the result with the saved data. When it comes to load the data back in, perform the same calculation and ensure that the result matches the result that was saved.

Continue reading