Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By : Michelle M Fernandez
Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By: Michelle M Fernandez

Overview of this book

Table of Contents (19 chapters)
Corona SDK Mobile Game Development Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – adding a main menu


We will create the frontend of our game by introducing the game title and the Play and Options buttons that will transition throughout different scenes in the application with ease.

  1. Create a new file called mainmenu.lua and import Composer and the UI modules, the composer.newScene() function, and the variables for timer and audio:

    local composer = require( "composer" )
    local scene = Composer.newScene()
    
    local ui = require("ui")
    
    local btnAnim
    
    local btnSound = audio.loadSound( "btnSound.wav" )
  2. Create the create() event. Add in the composer.removeScene( "maingame" ) and composer.removeScene( "options" ) lines, which will remove the "maingame" and "options" scenes. You can remove "maingame" after the player has transitioned from the main game screen and is sent to the main menu screen. You can remove "options" after the player has transitioned from the options screen and is sent to the main menu screen:

    -- Called when the scene's view does not exist:
    function...