1. Code
  2. Corona SDK

Create a Minigolf Game - Adding Interaction


This is the second installment in our Corona SDK minigolf 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 one of the series to fully understand and prepare for this tutorial.

1. Start Button Listeners

This function adds the necessary listeners to the TitleView buttons.

2. Show Credits

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

3. Hide Credits

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

4. Show Game View

When the Play 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 up in the next steps.

5. Game Background

First, we add the game background.

6. Instructions Message

The following lines add the instruction message. It will appear for two seconds and then fade it out.

7. TextFields

This part creates the TextFields on the stage. These show information about the maximum shots allowable for a par score and the current amount already made.

8. Ball

Add the ball to the level.

9. Hole

The next graphic will use physics to detect when the ball falls in the hole.

10. Walls

The level walls are created using the next few lines of code. They are invisible by default since we only need them to detect collisions with the ball.

11. Physics

Next we add physics to the game objects.

12. Game Listeners

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

13. Shoot Function

This next lines use the touch event and the physics applyForce method to shoot the ball.

14. Collisions

Now we'll check to see if the ball collides with the hole using the following code, and call an alert if true. This also checks the number of shots made and uses them to set the correct alert to display.

15. Alert

The alert function creates an alert view, animates it, and ends the game.

16. 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.

17. Loading Screen

Loading Screen

The Default.png file is an image displayed while the application loads. Add this image to your project source folder. It will automatically be added by the Corona compiler.

18. 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.

19. 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!

20. 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!


In this series, we've learned about physics behaviour, tap listeners, and collisions, skills that can be really useful in a wide number of games.

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

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

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