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:
Create a new file called
options.lua
and import Composer and the UI modules, thecomposer.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" )
Create the
create()
event. Add incomposer.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 incomposer.removeScene( "creditsScreen" )
. This will remove"creditsScreen"
after the player has transitioned from the credits screen back to the options screen:-- Called when...