28 November 2014
From the Forum — Issue #48
Welcome to the latest installment of From the Forum. In this series, guest blogger Alex Jackson highlights outstanding threads from the Corona Forum. The goal is to bring attention to the most captivating, interesting, and thought-provoking discussions taking place in our very own backyard.
Please visit the forum to join these conversations or start your own!
1. Convert HTML colors to hex values
With the switch to Graphics 2.0 solidly in our rearview, Corona developers are used to creating apps with RGB percent values instead of factors of 255. Several websites exist that help us determine the value based on color sample, or even the HTML code string, making life a bit easier in the process.
But we all want life to be as effortless as possible, don’t we? To that end, a Corona developer recently asked whether it was possible to get RGB percent values from HTML codes, and our favorite font of knowledge RoamingGamer delivered with a very useful snippet that converts the HTML string to the hex decimal value required by Corona.
Nice and tidy, and opens up an even greater bevy of options to developers looking to create RGB percent colors on the fly, based on different palette choices. Check out the original thread and see how simple life can be!
2. Bitmap fonts and the code that loves them
Getting our text objects to appear exactly how we want them across all OSes and devices can be a grueling march to the finish line. When we succeed, it looks that much better, but finding tools that help us get there can be difficult.
Which is why this bitmap font manager created by developer jjsanchezramirez is such a terrific gift to the Corona community. Looking to replace the necessity for programs like GlyphMaker, it helps create aligned text objects for fonts that can be treated like any simple display object, and modified just as easily. Gone are the days of having to buy a separate module just to have some simple text in your app!
Head on down to the original thread to pick up in the find. Have a suggestion or a tool of your own that you’d like to share? Don’t be afraid to let us know about it in the forum!
3. Organized chaos, easily contained!
We’ve all had times when we needed a little order to our swirling cacophony of randomness. Developing with Corona is no different. Perhaps you need to select from a pre-set amount of rubber cubes, perhaps you need to randomize dates, maybe you need to only offer certain clothing options to your user. Whatever the use case, having the ability to control your random selections is a good tool to have.
Learning more about the math.randomseed API can help with this. Fortunately, there was a discussion in the forum recently that trended along this very topic. Giving the math.randomseed logic a look-through, and coupled with some helpful advice from other Corona developers, the below forum thread gave us some great groundwork upon which to base future controlled random events and behaviors!
So what are you waiting for? Head to the original thread below to check out the tips and great the code snippet to see it in action. Have your own idea of how to accomplish this behavior? Don’t be afraid to chime in!
Alex Jackson is an indie developer and the founder of Panc Software, specializing in retro-style gaming. He has created several mobile applications, enjoys long walks on the beach, pixel art, and reading the Corona forums. Contact him by email or follow him on Twitter: @pancsoftware. Check out his new game Crosstown Smash on iOS, Android, and Amazon devices!