Cyber Monday Sale Save up to 40% off unlimited courses, tutorials and creative assets. Cyber Monday Sale! Save Now

# Corona SDK: Build a Shell Game - Final Steps

Difficulty:IntermediateLength:ShortLanguages:

Welcome to the final tutorial in our Three Shell game series! In this tutorial, we'll handle the shell animation, tap events, and the steps to build the final app.

## Where We Left Off. . .

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

## Step 1: Place Bet

This function runs when the BetBtn is pressed. It will subtract a credit from the bank and remove the listener from the button to avoid pressing it while the shells are moving.

## Step 2: Change Message

The message in the bottom will change depending on the current game state. The next line changes that message.

## Step 3: Reset Total Movements

The shells movements are calculated by this variable. Resetting the value will make the shells make the correct moves every time.

## Step 4: Hide Ball

The next line of code performs the tween that hides the ball using the shell. The function that moves the shells is called when the animation is complete.

## Step 5: Calculate Random Shell

This code uses Math to generate a number that will be used in the Table to select two random shells every movement.

## Step 6: Tween Shells

These lines of code are very important as they perform the animation of the shells. They calculate the final position of the selected shells based on its last position.

## Step 7: Check Moves Left

When the animation is complete, we check the moves left in our variable to determine if another shell movement should be made.

## Step 8: Add Shell Tap Listeners

If the shuffle part is complete its time to add interactivity to the shells and change the message instructions.

## Step 9: Reveal Ball

Any shell the player clicks will run this function. This part will remove the shell tap listeners to avoid unwanted behavior. It will also move the ball to the correct position and perform the animation that will make the ball visible. If the correct shell is selected it will add a credit to the bank. Finally, it will check if there are credits left in the bank to perform another game or it will call an alert if there aren't.

This function will stop the game by using the alert background and tweening it.

## Step 11: Restart

When the alert graphic is tapped, the graphics will be cleared and the app will start again.

## Step 12: Call Main Function

In order to initially 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 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 compiler.

## Step 14: 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 15: 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 should be ready for the final step!

## Step 16: 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!