02 October 2015
From the Forum — Issue #92
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. Wrap up those variables tight
Global and local scoping could be the most important skill to learn when starting in Lua in general, and Corona specifically. Mastering this concept is integral to having a lean, well-formatted project and keeping performance high.
Editing your variables easily, while keeping your scope module-appropriate was the basis of the below forum thread. The Corona developer who started the discussion was looking for a more simple method to edit their strings, as they would potentially have hundreds of variables that need to be modified. The Corona faithful came out to provide some solid suggestions, including Caleb P, who provided some useful code snippets for working and massaging the data.
Head down to the original thread to read up on how to handle this kind of data, and if you have your own suggestions for a solution, throw them in!
2. Users pushing users, just trying to get to know you
Using push notifications in your app is made incredibly easy when working with Corona. There are several push providers and user-maintained libraries that can be employed to bridge the gap between players, and make this big, scary world just a little bit smaller.
Having server infrastructure to facilitate push notifications is sometimes useful, but not necessary in most use-cases. This is very nice to keep in mind, as if you want to include this functionality in your app, but you don’t have the bandwidth to research and/or maintain a server. A Corona developer recently was looking for this type of implementation, and came up big after doing some research on third party services that work very well with Corona.
Skip down to the original thread to learn more about this method!
3. Important note about Graphics 2.0 filters!
This is more of a PSA than a good tip, but it’s important nonetheless and I want to make sure that other developers do not fall into the hole of countless hours of testing, trying to find an already-diagnosed issue.
There are two shader filters (hue and brightness, specifically) that, in the words of a core Corona engineer, do not “not support transparent regions for performance reasons because supporting zero alpha in a texture would require an if-else branch in the shader. If you apply the hue filter on a texture with regions of zero alpha, you will get undefined behavior in those regions (divide by zero is undefined in a shader), meaning the end result will vary from device to device.”
There are two solutions here for this issue: Discontinue use of the shader and work around the missing functionality in your graphics assets, or generate your own custom shader effect to replicate the filter functionality. The Corona engineer highlights the best way to create the filter, so you’ve got a leg up. If you’re running into this problem, head over to the original thread to great those tips!
Alex Jackson is an indie developer and the founder of Panc Interactive, 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: @pancinteractive. Check out his new game Segreta on iOS, Android, Windows Phone and Amazon devices.