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 an options menu


We'll add an options menu that can be accessed through the main menu. We're going to add a new UI button called Credits, which will direct the user to the credits screen once it is pressed. To add an option menu perform the following steps:

  1. Create a new file called options.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 composer.removeScene( "mainmenu" ), which will remove the "mainmenu" scene. This will occur after the player has transitioned from the main menu screen and is sent to the options screen. Next, add in composer.removeScene( "creditsScreen" ). This will remove "creditsScreen" after the player has transitioned from the credits screen back to the options screen:

    -- Called when...