Developing a game to the point of completion is a great accomplishment. It's one step closer to sharing it with the rest of the world, so that other people can play your new game. The benefit of creating your game with Corona SDK is that you have the option to build for iOS and/or Android. You want to ensure that your application is ready for submission so that it can be distributed in the mobile platform you're developing in. We'll go over the process of what it takes to prepare your game for its release.
In this chapter, we will cover the following topics:
As you develop your application, you should always consider how your design choices affect the performance of your application. The device memory still has its constraints even though there are improvements in the computing power and memory. Performance and optimization within the device will not only achieve faster response times, but also help minimize memory usage and maximize battery life. A link to an example on how to check memory usage can be found at https://gist.github.com/JesterXL/5615023.
Memory is an important resource on mobile devices. When too much memory is being consumed, devices may be forced to quit your application when you least expect it. Here are some things to be aware of while developing:
nil
in your code (myVariable = nil
).display.remove( myImage ); myImage = nil
or myImage:removeSelf()
.Here is an example:
local box = display.newRect( 0, 50, 100, 100) box:setFillColor( 1, 1, 1) box.alpha = 1 local function removeBox() if box.alpha == 1 then print("box removed") display.remove( box ) box = nil end end timer.performWithDelay( 1000, removeBox, 1 ) -- Runs timer to 1000 milliseconds before calling the block within removeBox()
Display images have a way of taking up a lot of texture memory if you're not paying attention to the size and number of images being used all at once.
If a property of several objects is set to the same value, it's preferable to add the objects to a group and then modify the property of the group. It'll make it much easier for you to code, and it optimizes your animation.
It's easy to forget to stop animations from running in the background when they're not needed or when you've made them invisible.
When you include a listener such as "enterFrame"
and the objects registered under the listener have been set to .isVisible = false
, it'll continue to run in the background even though it is not seen on screen. Make sure that listeners are removed when they are not needed.
When you have large file sizes, especially full-screen images, the responsiveness of your application will slow down because of the time it takes to load, and plus, it uses up a lot of memory. When using large images, try compressing the file size as much as you can with an image-editing tool, such as Photoshop or ImageOptim (https://imageoptim.com). It'll help reduce the file size and save you the pain of application lag. Compressing large image sizes will benefit you in the long run. If images are backgrounds, consider switching to tiled images.