Call Us: 866.PICK.ITS or Have Us Contact You:
The mobile app space offers an ecosystem of development environments to choose from depending on your specific needs. There is no one-size-fits-all solution, and there are many factors to consider when making your selection such as target audience, design and functionality requirements, user needs, programming teams experience, budget, etc. It’s important to include this strategic decision during the early stages of the process because selecting the wrong development platform can be the difference between great success and tremendous frustration. In this article we will introduce you to Corona SDK, when to consider it for your mobile application development, and give you tips for getting started.
Corona SDK is a specialty platform that has become popular in the gaming and educational app space for its ability to produce complex animations and advanced visualizations that can run across any device. Corona SDK has also proven to be an effective option for building custom business applications that require interactive functionality and graphics.
An Integrated Development Environment (IDE) / Software Development Kit (SDK), Corona SDK offers cross-compiling functionality so programmers can write, test, and deploy their application all in one program. It is a great option for programmers that need to enter the mobile sector quickly for its simple scripting language and low upfront costs. It’s especially helpful to those fledgling programmers who might be intimidated by the otherwise steep learning curve associated with mobile programming.
Corona SDK’s main feature is its built-in simulator. Unlike other platforms like Xamarin which still require access to a Mac in order to deploy iOS apps, Corona SDK’s internal interpreter doesn’t rely on native modules (e.g. Mac-exclusive kernel extensions, etc.) for demoing code. Instead, code is directly run inside Corona SDK and displayed in a simulation window. This has the added benefit of trying out your changes without the cumbersome need to compile and deploy. Some other mobile IDEs offer similar options on their native platforms, but Corona SDK allows instant testing regardless of platform.
Corona SDK uses the Lua scripting language, which provides a simple programming structure for the developer. Similar to the popular Python programming language and other indent-based languages, Lua eliminates the need to worry about adding brackets and semi-colons, which plagued programmers in the past when compile-time errors were not very helpful. In addition, it does not require initializing variables prior to assigning them, and allows the programmer to define global variables for use throughout the program. Features like these can help increase productivity for new developers.
Sample Lua Script; note the use of indentation to delineate statements like Python
Perhaps one of the best features of Corona SDK is the ability to distribute to multiple platforms with a single codebase. Let’s say you built an iPhone application with Apple’s native Xcode/Objective-C platform and then later decided you want to deploy to Android as well, you would have to rebuild your entire application from scratch as an Android application before going to market. Corona SDK works as an intermediary to transform your Lua scripting into deliverables on multiple platforms, enabling you to concentrate your efforts on one codebase without limiting your market options.
When beginning a mobile project with Corona SDK, there are a few common roadblocks you may come across. Here are five tips to keep in mind as you delve into the mobile development process with Corona SDK:
1) Read the Manuals: The official Lua documentation is extensive and has a lot of great information to offer. Programming in Lua is a great resource to add to your arsenal. Starting a new language can be daunting, but this book will help you get on your feet quickly. Not only is it a good resource for learning the language, it’s also very detailed in programming conventions and paradigms such as object-oriented programming (OOP). Corona SDK even has the first edition freely available online in an easy-to-peruse HTML format.
2) Functions are Variables: Lua is a very versatile language in that even functions are considered first-class citizens and as such can be created, stored, manipulated, etc. in much the same way as variables. It’s entirely possible to have your function be defined at runtime by storing the function definition within another function, but doing so can make the code difficult to review and maintain. Therefore it’s important to remember to have clear separation of definition and function calls. Be sure to stick to common coding conventions (even when the coding framework allows otherwise), to make maintaining the codebase easier for future developers (yourself included!).
Defining a function within a function makes code maintenance difficult.
3) Reach Out to the Community: One of the most frustrating scenarios for a developer is debugging issues that do not produce exceptions or error codes. I ran into a bug where my users would tap an object, and even though the tap successfully registered, it continued to also tap what was behind it - almost as if the tap never stopped and just kept going until it hit the back of the screen. After a very frustrating couple of days, I searched the web and almost immediately found my answer: return. I had missed the simple fact that I needed to return something at the end of my touch-event functions, which in turn continued to trigger tap events for the objects hidden behind as well. When something seems buggy but isn’t throwing you any exceptions or error codes, save yourself the frustration and conduct a simple Google search. You’ll discover fellow developers have encountered similar issues and have generously documented how to fix them.
4) Be Careful with Asynchronous Callbacks: Lua supports asynchronous callbacks. This means that the program can call a function at a future point in time, and the point at which it is called may not always be at the same point. I ran into an issue where my main program used the “blackoutImage” variable. The callback occurred sooner than I expected and nulled out the variable while my main program was still using it, causing a null reference exception when the program tried to access it. It’s important to keep track of your functions running and plan ahead for this during the development process. It can be very easy to lose track of which functions are running, and you can end up with exceptions or even overlapping screens and menus if you aren’t careful.
5) Use Guard Code: Along with asynchronous functions, it can also be easy to lose track of variables and stored objects. Calling a function for an object from another function can cause exceptions if you aren’t capturing all of your use cases, especially when removing objects from memory. Asynchronous behavior makes it much easier to mistakenly call a method for a nil object, and using guard code (checking for a nil object) can help avoid issues.
Code snippet of a Callback being defined. The call back runs separately alongside the current routine. In some cases, the current routine might nil out the blackoutImage variable before the callback occurs. Without the guard code checking for nil here in the commented code, this would throw a nil reference exception when the callback attempts to call the removeSelf function.
Before diving headfirst into programming, make sure you take the time to do your research and select the platform that best fits your specific mobile app needs. While Corona SDK is a great option for building apps with rich multi-media content across multiple operating systems, it’s not necessarily the only (or the right) development platform to do the job.
If you are considering building a custom mobile application but unsure which platform to use, IT Solutions can guide you through the process. For more information about IT Solutions’ mobile development process, click here. If you would like to talk with our Application Development team about your mobile app needs, contact us at 1.866.Pick.ITS.