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.
Create a new file called
mainmenu.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 in thecomposer.removeScene( "maingame" )
andcomposer.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...