Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From \$16.50/m

# Create a Hundreds-Like Game - Adding Interaction

Difficulty:IntermediateLength:ShortLanguages:

This is the second installment in our Corona SDK Hundreds game tutorial. In today’s tutorial, we’ll add to our interface and the game interaction. Read on!

## Where We Left Off. . .

Please be sure to check part 1 of the series to fully understand and prepare for this tutorial.

## Step 1: Start Button Listeners

This function adds the necesary listeners to the TitleView buttons.

## Step 2: Show Credits

The credits screen is shown when the user taps the about button, a tap listener is added to the credits view to remove it.

## Step 3: Hide Credits

When the credits screen is tapped, it'll be tweened out of the stage and removed.

## Step 4: Show Game View

When the Start button is tapped, the title view is tweened and removed revealing the game view. There are many parts involved in this view, so we'll split them in the next steps.

## Step 5: Game Background

This code places the game background image in the stage.

## Step 6: Walls

Next we add the walls to the stage. They are created using the drawing API.

## Step 7: Circles

This part creates five circles in the screen at a random position, the i variable is used to multiply a constant that will define the circles color making it lighter each time. A textfield is also created and both are held within a group to move them together.

## Step 8: Circle Physics

Here we add physics to our new circle.

## Step 9: Wall Physics

And do the same with our walls.

## Step 10: Score TextField

Now we add the score textfields.

## Step 11: Game Listeners

This function adds the necessary listeners to start the game logic.

## Step 12: Increase Score

This code runs when the circle is touched.

First we increase the score.

## Step 13: Increase Size

Then the size of the circle. The circle will grow when the finger is no longer on it.

## Step 14: Change Color

Changes the color from black/gray to red.

## Step 15: Update Circle

We recreate the circle and its properties when the touch event has ended.

## Step 16: Level Complete

Here we check if the score has reached 100 points and call a win alert if true.

## Step 17: Collisions

The game is lost when a pressed circle collides with another one. The listeners are removed and a lost alert is called.

The alert function displays a message according to the type of alert called.

## Step 19: Call Main Function

In order to start the game, the Main function needs to be called. With the above code in place, we'll do that here:

The Default.png file is an image that will be displayed right when you start the application while the iOS loads the basic data to show the Main Screen. Add this image to your project source folder, it will be automatically added by the Corona compliler.

## Step 21: Icon

Using the graphics you created before you can now create a nice and good looking icon. The icon size for the non-retina iPhone icon is 57x57px, but the retina version is 114x114px and the iTunes store requires a 512x512px version. I suggest creating the 512x512 version first and then scaling down for the other sizes.

It doesn't need to have the rounded corners or the transparent glare, iTunes and the iPhone will do that for you.

## Step 22: Testing in Simulator

It's time to do the final test. Open the Corona Simulator, browse to your project folder, and then click open. If everything works as expected, you are ready for the final step!

## Step 23: Build

In the Corona Simulator go to File > Build and select your target device. Fill the required data and click build. Wait a few seconds and your app will be ready for device testing and/or submission for distribution!

## Conclusion

Experiment with the final result and try to make your custom version of the game!

I hope you liked this tutorial series and find it helpful. Thank you for reading!