Let The Corona Blitz Begin!

Posted: August 17, 2013 in Corona SDK, Hackathon

Hello World,

I love hackathons. These short, intense bursts of rapid application development can certainly test your “metal”. But more importantly, I like participating in these event because they really test my skills as an application developer. Well, the latest of these kind of events is the CoronaBlitz – A Semi-Regular Mini Coding Challenge. This semi-regular event is organized by Andrew Potozniak, an indie developer and founder of TozSoftware.

So What Is The CoronaBlitz?

This is a coding challenge in which you have 4 hours to develop a mobile app using the Corona SDK and any 3rd party tools that may help you along the way. There is no prize money. There are no trip giveaways. Those of us participating do so for the love of coding and learning (and maybe a bit of SWAG and recognition for our work). Unlike many other hackathons this event does not require you to show up at a specific venue. All the coding is done on your own time in a location of your choosing (your office, living room, bed!?). Each coding challenge happens over the course of several days but the organizer trusts that you will spend only 4 hours total coding your app – in one sitting or broken up over the course of the event (is there such a thing as a “Code” among coders?) Each blitz event will have a theme that you should adhere to. This theme for this blitz is Collection.

Time To Enter The Fray

The current blitz started on August 16th and lasts until August 25th and I plan on spreading out my 4 hours over the course of the 9 days. My goal is not to simply “hack” together something within that time but rather to create a working app that can be used as a teaching tool for those wishing to learn the Corona SDK. This means that I will be doing short (30 – 45 minutes) coding sessions focused on one or more specific functionalities or tasks. Afterwards I will post details of my progress here on this blog. In between each of the coding sessions I will plan my next step and gather the resources (images, audio, libraries, etc) I may need to accomplish the next task. In the end I hope to have put together a video tutorial showing you how I built the app and explaining some of the features I have included.

The Discovery Of An Idea

It was very difficult for me to discover the app I will be creating for this blitz. I say “discover” because that’s the best way for me to find with ideas for new projects. I keep my mind open at all times for bits of inspiration from everyday life to the movies I watch to the other apps I see to the many people I interact with. I never know when and where the inspiration may reveal itself. So I keep a log of ideas and inspirations on my cell phone.

It took a few days before the idea for this app revealed itself. I still remember and love playing games like PacMan, Space Invaders, and Asteroids. As I was think about the theme one day I saw a picture of Space Invaders while browsing the net. Couple that with the fact that I am a huge Star Trek fan, I started thinking about the Borg Collective. So why not create a game that combines the simplicity of Space Invaders with the concept of the Borg thereby adhering (as best as I can) to the theme “Collection”. This was born.

“The Return of the Space Invaders: The Collective!”

First I had to come up with a story. The story will help me define the game concept and how it should be played.

The Space Invaders Are Back with a vengeance! Although they look the same they have formed into a collective that acts, behave, and thinks alike. They also learned how to “collect” and assimilate other life forms into their collective thus making their army stronger. You must fight off the attacks of the Space Invaders and prevent them from collecting too many of our citizens for their evil purposes.

Well there you have it. The beginning of a game. So what do I need as far as resources for the game? First I need images. Let me say that I am not a designer. I don’t know how to use Photoshop. However I can do wonders with clip art. I have been using Fireworks for several years (Corel Draw before that). I have a collection of millions of images on CDs and hard drives. So I need to find existing images that I can alter to suit my purposes. I plan on using the same Space Invader alien images from the 70s.

Space Invader Aliens

That will give it a retro look and feel. The background and other images will have a more contemporary look. I will use images of a tank to replace the missile defence. Instead of buildings standing between the aliens and the tanks I will have floating shields. The concept is that earth defenses have advanced enough to create and activate invisible (almost) defense shields that help defend against the attacks. Of course since the alien weapons can not penetrate the defense shields neither can our weapons (Star Trek logic). So the shields will randomly rotate with gaps in-between allowing us to fire through (and the also the aliens). Below the tank will be little people randomly walking back and forth. These are the people you must defend against assimilation. Should one of the alien’s weapons hit a citizen that citizen will be added to the collective with the aliens above. Every addition to their collective increases the level of difficulty. Just as in the original game the aliens will always be advancing downward. Your weapons can only destroy the aliens (sorry, you can’t save any assimilated citizens). Should the alien force breach the shielding, all the citizens will be assimilated and the game is over. Should an alien weapon hit the tank then you have been destroyed, the defensive shields will fail, and all the citizens will be assimilated. You get only one life (just like in real life). Should you destroy all the aliens then you win and get points for all the remaining citizens you were able to save.

I bought some clip art from one of my stock image sources – DepositPhotos.com. I was then able to isolate and save the images as individual files. Then I created a sprite sheet for most of the images (not the background image) using Texture Packer. I found this to be the best and easiest to use sprite sheet generator on the market. Since this is a coding challenge I do not count the work I did to gather and process the images towards the four hours given to us in the Corona Blitz.

I am now ready to start coding. My first set of tasks will be to create the Corona SDk app, setup the application folders, add the various helper libraries I use in many of my projects, create the splash screen, and the instructional screen. This should take less than an hour. Once I am finished I will post details and screenshots about my experience and what was done.

See you in a couple of days!


Hello World,

For the past couple of weeks I’ve been having a lot of fun playing around in Kii. No, I’m not talking about the former province in Japan nor am I refering to the Hawaiian deity (actually spelled Ki’i). The Kii that I speak of is a Backend as a Service (known as BaaS) by a company of the same name. What exactly is Kii?
Kii Cloud
The Kii Cloud enables developers to focus on application development and leave the User and Data Management, Analytics, Monetization, and Push Notification services to the Kii Cloud though the use of APIs and SDKs. Kii already provides APIs, Guides, and Sample Code for IOS, Android, and Javascript-based platforms as well as a REST implementation. The Javascript implementation was easy to learn and implement but my desire was to see if I could use the Kii Cloud from within a Corona SDK app. And By Golly … Yes I Can!

In this post I will show you how to sign up for an account on Kii and then show you some sample code you can use in your Corona app.


Signing up for a Kii Cloud account easy and you can get started for free! If you haven’t already sign up for an account by going to their site: http://www.kii.com

Create Your First App

After you have successfully signed up for an account you are now ready create your first Kii Cloud app! once you sign into Kii and you will be taken to the Developer Portal in your account. Click on the Create App button to begin the process of creating your first app.


Specify App Properties

A new dialog will appear enabling you to specify your new app properties. You will enter the Kii app name, select United States (unless you live in Japan or China), and select the radio button next to the HTML5 icon.


App Dashboard

Your new Kii app will now appear in your App Dashboard. From here you will be able to see statistics and other related information about your app.


App ID and KEYS

Your new Kii Cloud app will will be assigned several alphanumeric ids and keys. To view those keys click on your new Kii Cloud app from your App Dashboard. Once you have entered your Kii Cloud app screen find and click on the Access Keys button on the top right section of the screen.


Doing this will display a popup showing your App ID, App Key, Client ID, and Client Secret. The only two you need to be concerned with are the App ID and App Key.


Copy and paste those two values into a text editor. You will need them later.

Your Corona SDK App

Now we’re ready to take a look at some of the sample code that will enable you to communicate with your Kii Cloud app.

I found that the easiest and most direct way to interact with the Kii Cloud from a Corona SDK app was to use the RESTful API. The network.request method enabled us to just that.

Here is some Corona (Lua) code used to SignUp a user using the Kii RESTful API

local function userSignUp( obj )
	if (not obj.loginName or not obj.password or not obj.email) then
print("Missing login data")
		local baseURL = "https://api.kii.com/api/apps/"
		local appId = "????????" -- Your AppId
		local appKey = "????????????????????????????????" -- Your AppKey

		local headers = {}
		headers["content-type"]		= "application/vnd.kii.RegistrationRequest+json"
		headers["x-kii-appid"]		= appId
		headers["x-kii-appkey"]		= appKey

		local params = {}
		params.headers = headers
		params.body = value.encode ( obj )

		network.request( _BASEURL .. appId .. "/users", "POST", networkListener,  params)

The method above expects one parameter: a Lua table containing keys and values. The key/values that it expects are: loginName, password, and email. Although this Kii API method does not require all three of these values I am validating their existence just for this example.

The base URL used for all your calls to the Kii Cloud (unless you live in Japan or China) is assigned to the baseURL variable.

Remember the App ID and App Key you copied earlier? Now you can copy and pasted those values into your code and assign them to the appId and appKey variables.

If you take a look at the Kii Cloud documentation (http://documentation.kii.com/en/guides/rest/) you will see examples calls to each of their API methods. The REST API documentation shows examples using CURL. CURL is a command line tool used to transfer data to a or from a networked server. You can get more information about CURL here – http://curl.haxx.se/docs/manpage.html.

curl -v -X POST \
-H "content-type:application/vnd.kii.RegistrationRequest+json" \
-H "x-kii-appid:{APP_ID}" \
-H "x-kii-appkey:{APP_KEY}" \
"https://api.kii.com/api/apps/{APP_ID}/users" \
-d '{"loginName":"user_123456", "email":"user@123456.com"}'

We are then able to translate this command line call into a Lua code by assigning the three Headers (the three -H values) to the three Lua variables. Then we assign the headers to a params table variable. The obj parameter (passed into the function) is then stored in the params table variable.

Finally the network.request method is called, passing in the entire URL (a concatenation of the _BASEURL, appId, and the remaining portion of the URL). The network.request method is an asynchronous method. This means that your Corona code will continue to execute until it is notified of the Kii Cloud method completion. This is the purpose of the next argument, networkListener. This is the callback method that is used to handle the response. You can get more information about the network.request method here: http://docs.coronalabs.com/api/library/network/request.html

function networkListener( response )
	if not response.errorCode then
		print("response.access_token: " .. response.access_token)
		print("response.errorCode: " .. response.error_description)

Once the Kii Cloud REST API method is completed it will call the networkListener method shown above. An object containing information about the call will be passed into your callback method. In this sample code we are only interested in either the access_token (which is used in many of the subsequent calls) or the errorCode.

Here is a sample call to userSignUp method described above.

userSignUp( {loginName=obj.testUser, password=obj.testPassword, email=obj.testEmail} )

As you see we are able to create a new user in our Kii Cloud app using the simple and straightforward code shown above. In fact I had so much fun working with the Kii Cloud API that I decided to write an entire library containing all the calls to the REST API. Once completed I will release the library into the “developer wild” for anyone to use. Keep your eye on this blog as I will post a link to the library source very soon.


Quote  —  Posted: July 21, 2013 in Corona SDK, Kii Cloud
Tags: ,

Hello World,

Memorial weekend just passed (Thanks To All Our Veterans!!) and it was a nice relaxing three day weekend. So what did I do? Go to the beach? See a movie? Go to a parade? Have a cookout? None of the above. I was writing code!

I decided to challenge myself by creating a mobile app from scratch on Memorial day. So I spent the Saturday and Sunday trying to generate an idea for a mobile app that I could do within an 8 hour period. I realized that I have several young nieces and nephews that are starting to use their parent’s mobile devices. So why not create an app that would appeal to them? That’s exactly what I did. I promised myself that I would start Monday morning and stop before Monday at midnight. Here is what I was able to create in a little less than 8 hours (I took some time to participate in a meeting and eat that day):

A cute little game I created from scratch in under 8 hours using the Corona SDK.

As you see it’s a very simple app (relatively speaking) that was created using The Corona SDK by Corona Labs. Why Corona? Well, for me it was a no brainer. After a little more than a year of learning the Corona SDK and the Lua language. I found them to be the fastest and easiest way to create powerful mobile apps – not just games. I still like (and use) Javascript but I now consider the Corona SDK and Lua to be my “go to” tools for building mobile apps. You will be seeing many more Corona SDK-specific posts on this blog!

I hope to complete the app and publish it to the app store sometime in the near future. After all, my nieces and nephews won’t stay young forever. In the meantime I may push the source code onto my Github account. At the very least I may post some of the more interesting snippets of code on this blog.

Until then …