1. Code
  2. Corona SDK

Corona SDK: Develop a Frenzic-like Game - Application Setup

This post is part of a series called Corona SDK: Develop a Frenzic-like Game.
Corona SDK: Develop a Frenzic-like Game - Adding Interactivity

In this Tutorial series, we'll use the Corona SDK to build a Frenzic Inspired Game. This tutorial will focus on the application setup and core structure in 15 steps. Read on!

Step 1: Application Overview


Using pre made graphics we will code an entertaining game using js and the Corona SDK API's.
The user will be able to play against time to complete the square containers by tapping in them. Filling a container with a single color gives more points!

Step 2: Target Device


The first thing we have to do is select the platform we want to run our app within, this way we'll be able to choose the size for the images we will use.

The iOS platform has these characteristics:

  • iPad: 1024x768px, 132 ppi
  • iPhone/iPod Touch: 320x480px, 163 ppi
  • iPhone 4: 960x640px, 326 ppi

Because Android is an open platform, there are many different devices and resolutions. A few of the more common screen characteristics are:

  • Google Nexus One: 480x800px, 254 ppi
  • Motorola Droid X: 854x480px, 228 ppi
  • HTC Evo: 480x800px, 217 ppi

In this tutorial we'll be focusing on the iOS platform with the graphic design, specifically developing for distribution to an iPhone/iPod touch, but the code presented here should apply to Android development with the Corona SDK as well.

Step 3: Interface


A colorful nice looking interface will be displayed, this involves multiple shapes, buttons, bitmaps and more.
The interface graphic resources necessary for this tutorial can be found in the attached download.

Step 4: Export Graphics


Depending on the device you have selected, you may need to export the graphics in the recommended ppi, you can do that in your favorite image editor.
I used the Adjust Size... function in the Preview app on Mac OS X.
Remember to give the images a descriptive name and save them in your project folder.

Step 5: Sound


We'll use Sound Effects to enhance the feeling of the game, you can find the sounds used in this example in using the keywords bell and buzz.

Step 6: Build Settings

Before writing any code we'll define a few options by creating a build.settings file. This file contains parameters that will be applied to the final build of your program as well as the font that we want to embed in our app.

Step 7: App Configuration

Another external file will be used to scale the application to fullscreen across devices, the config.js file.

This file shows the original screen size and the method used to scale that content in case the app is run in a different screen resolution.

Step 8: Main.js

Let's write the application!
Open your prefered js editor (any Text Editor will work, but you won't have syntax highlighting) and prepare to write your awesome app. Remember to save the file as main.js in your project folder.

Step 9: Code Structure

We'll structure our code as if it were a Class. If you know ActionScript or Java, you should find the structure familiar.

Step 10: Hide Status Bar

This code hides the status bar. The status bar is the bar on top of the device screen that shows the time, signal, and other indicators.

Step 11:Title View


This is the main application screen, it will be the first interactive view to appear in our game. These variables store the background and the TitleView components.

Step 12: Score & Lives


The following variables store the lives and score texts as well as its value.

Step 13: Containers


These graphics will have a tap listener in order to move the squares to the predefined position, fill them to win points!
Another variable is declared in this code, a group that will store all the graphics shown in the game screen.

Step 14: Blocks


Three blocks will be available in the game, fill a container with a single block color to win bonus points. The blocks will be added to the game randomly and stored in a table that we'll create later.

Step 15: Credits


This screen will show the credits, year, and copyright of the game. This variable will be used to store a reference to the view:

Step 16: Variables

These are the variables we'll use, read the comments in the code to know more about them, some of their names are self explaining so there will be no comment there.

Step 17: Code Review

Here is the full code written in this tutorial alongside with comments to help you identify each part:

Next Time...

In this part of the series you've learned the interface and the basic setup of the game. Stay tuned for part two where we will handle the different screen views and start placing the graphics in stage to build the interface. See you next time!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.