Creating Circle Pop – Part 2

Hello and welcome to another Corona SDK tutorial by That’s So Panda! In Part 1 of our tutorial series, we were introduced to a game called Circle Pop. In this introduction, we learned how the player will play the game, the functionality and the file structure. In Part 2 of our tutorial, we will be learning more about the build.settings and config.lua files. So, let’s get started!

If you would like to purchase this as a template to support this website or to avoid having to retype all of this code, you can buy the template at thatssopanda.com/corona-sdk-templates/.

Although some tutorial do not cover the build.settings and config.lua files (even some of my don’t), I wanted to briefly touch on these two files because they are essential to any professionally made app. These files will handle all of the options your app can do with Corona SDK. To get started, let’s take a look at the build.settings file.

The build.settings can be as simple or as complex as you want it. At the minimum, you only need to have one table called settings inside your build.settings file.

settings = {
}

Although this is the only required piece of code, you will want to add more information to the table to get the most out of your app. In our case, we want to add the orientation table to our settings table to only allow our players to play in portrait mode or portrait upside down mode. This lets them play their phone upright or upside down if they are playing on their head. Here’s how:

settings = {
    orientation = {
        default = "portrait",
        supported = { "portrait", "portraitUpsideDown"}
    },
}

Now that we’ve added an orientation table to our file, we will want to hide that ugly status bar that shows up on the iPhone. Here’s how:

settings = {
    orientation = {
        default = "portrait",
        supported = { "portrait", "portraitUpsideDown"}
    },
    iphone = {
        plist = {
            UIStatusBarHidden = false,                
    },    
}

Pretty simple right? There are a plethora of settings you can put into your build.settings file, but for our game, this will do. Next, let’s look at the config.lua file.

The config.lua file handles all of the runtime properties of our app such as width, height, scale type and frames per second. This file can also handle dynamic scaling and more advanced topics, but I’m saving that for a later tutorial. For now, let’s take a look at the config.lua file all at once.

application = {
    content = {
        width = 320,
        height = 480, 
        scale = "letterBox",
        fps = 30,
    },
}

This file accepts one table called application and has a nested table called content. Inside of our content table, we have set the width of our app to 320 pixels, the height to 480 pixels, the scale to letterbox and the frames per second to 30. The width, height, and frames per second are self explanatory, the scale setting is not. I’ve set the scale to letterbox because it will uniformly scale content as much as possible while still keeping the aspect ratio and display all of the content on the screen. This is very similar to widescreen mode in DVDs. Finally, I could definitely have included more configurations, this will get us through the game.

So that’s it for Circle Pop Part 2! We’ve learned why we use build.settings and config.lua in our Corona SDK app. Below is the full source code for build.settings and config.lua. If you have any questions, please let me know in the comments! If not, get ready for part 3!

build.settings

-- Supported values for orientation:
-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {

    orientation = {
        default = "portrait",
        supported = { "portrait", }
    },

    iphone = {
        plist = {
            UIStatusBarHidden = false,                
    },

}

config.lua

application = {
    content = {
        width = 320,
        height = 480, 
        scale = "letterBox",
        fps = 30,
    },
}

Leave a Reply