Indeed, the buttons are still active, which I do not want to.
Here is my pause.lua:
local composer = require( "composer" ) local scene = composer.newScene() local globalData = require( "globalData" ) local databaseModuleVar = require("databaseModule") function saveGame(saveName) -- handle DB backup return true end -- "scene:create()" function scene:create( event ) local sceneGroup = self.view end -- "scene:show()" function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then local overlayWidth = display.contentWidth local overlayHeight = display.contentHeight local myRectangle = display.newRect( overlayWidth/2, overlayHeight/2, overlayWidth, overlayHeight ) myRectangle:setFillColor( 1, 1, 1, 1, 0.5 ) --myRectangle:toFront() sceneGroup:insert( myRectangle ) local filenameField local function textListener( event ) if ( event.phase == "began" ) then -- User begins editing "filenameField" elseif ( event.phase == "ended" or event.phase == "submitted" ) then local result = saveGame(event.target.text) composer.hideOverlay() sceneGroup:remove(filenameField) elseif ( event.phase == "editing" ) then end end filenameField = native.newTextField( overlayWidth/2, overlayHeight/2, 800, 200 ) native.setKeyboardFocus( filenameField ) filenameField:addEventListener( "userInput", textListener ) sceneGroup:insert(filenameField) end end -- "scene:hide()" function scene:hide( event ) local sceneGroup = self.view local phase = event.phase local parent = event.parent -- Reference to the parent scene object if ( phase == "will" ) then -- Call the "resumeGame()" function in the parent scene parent:resumeGame() end end -- "scene:destroy()" function scene:destroy( event ) local sceneGroup = self.view end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene
And part of my game.lua (parent scene) :
-- Enable zooming when the screen is pinched qiso.enablePinchZoom() -- Enable camera panning when the screen is dragged qiso.enableCameraPan() -- Enable the main Qiso loop to render/update our world qiso.activate() -- Load and show the toolbar local toolbar = require("toolbar") toolbar.loadBottomToolbar() function scene:resumeGame () local sceneGroup = self.view local gameSavedConfirmation = display.newText( "Game saved as "..globalData.currentGameName, 300, 200, native.systemFont, 0, left ) gameSavedConfirmation.x = gameSavedConfirmation.width/2 -- set offset of half the width of the text area gameSavedConfirmation.y = gameSavedConfirmation.height\*2 -- set offset of half the height of the text area gameSavedConfirmation:setFillColor( 1, 1, 1 ) sceneGroup:insert( gameSavedConfirmation ) transition.fadeOut( gameSavedConfirmation, { time=6000 } ) end function overLay () local options = { isModal = true, effect = "fade", params = { sampleVar = "my sample variable" } } composer.showOverlay("pause", options) end globalData.saveButton:addEventListener("tap", overLay)
Finally, my toolbar module:
local M = {} globalData.buildingBarGroup = display.newGroup() -- Create a new display group for the building bar icons function M.loadBottomToolbar() -- Menu bar at the bottom, containing different modes local widget = require("widget") globalData.toolbarGroup = display.newGroup() -- Create a new display group for the toolbar bar icons globalData.toolbarGroup.alpha = 1 -- Display the toolbar globalData.deleteButton = widget.newButton( { width = 150, height = 150, defaultFile = "delete.png" } ) globalData.deleteButton.x = 75 globalData.deleteButton.y = display.contentHeight-75 globalData.toolbarGroup:insert( globalData.deleteButton ) -- insert button into toolbar group -- More buttons here... end return M
Thanks for the work on the opacity functions