I have a menu that allows a player to choose between human vs human game or human vs computer. The problem I am having is that when the player touches the human vs human button is transitions to the new scene with the buttons from the previous scene still showing. Can anyone give me advice as to how to fix this.
This is the code from the first scene - playerMenu.lua
local composer = require( "composer" ) local scene = composer.newScene() local widget = require("widget") local function gotoHvh() composer.gotoScene( "hvh" ) end local function gotoHvc() composer.gotoScene( "hvc" ) end local function HvhHandleButtonEvent(event) if ("began" == event.phase) then gotoHvh() end return true end local function HvcHandleButtonEvent(event) if ("began" == event.phase) then gotoHvc() end return true end --setup the buttons local hvhButton = widget.newButton{ id = "hvhButton", -- id is unique and essential when using event handlers (see addEventListener below) shape = "roundedRect", x = x, y = y, width = 124, height = 124, cornerRadius = 2, fillColor = {default={ 1, 0.2, 0.5, 0.7 }, over={ 1, 0.2, 0.5, 1 }}, strokeColor = {default={ 0, 0, 0 }, over={ 0.4, 0.1, 0.2 }}, strokeWidth = 4, onEvent = HvhHandleButtonEvent, label = "Human vs. Human" } local hvcButton = widget.newButton{ id = "hvcButton", -- id is again unique shape = "roundedRect", x = x, y = y, width = 124, height = 124, cornerRadius = 2, fillColor = {default={ 1, 0.2, 0.5, 0.7 }, over={ 1, 0.2, 0.5, 1 }}, strokeColor = {default={ 0, 0, 0 }, over={ 0.4, 0.1, 0.2 }}, strokeWidth = 4 , onEvent = HvcHandleButtonEvent, label = "Human vs. Computer" } hvhButton.x = 100 hvhButton.y = 100 hvcButton.x = 250 hvcButton.y = 100 return scene
and this is the code from the scene it is transitioning to which shows the board - hvh.lua
local composer = require( "composer" ) local scene = composer.newScene() d = display w20 = d.contentWidth \* .2 h20 = d.contentHeight \* .2 w40 = d.contentWidth \* .4 h40 = d.contentHeight \* .4 w60 = d.contentWidth \* .6 h60 = d.contentHeight \* .6 w80 = d.contentWidth \* .8 h80 = d.contentHeight \* .8 ----DRAW LINES FOR BOARD local lline = d.newLine(w40,h20,w40,h80 ) lline.strokeWidth = 5 local rline = d.newLine(w60,h20,w60,h80 ) rline.strokeWidth = 5 local bline = d.newLine(w20,h40,w80,h40 ) bline.strokeWidth = 5 local tline = d.newLine(w20,h60,w80,h60 ) tline.strokeWidth = 5 --PLACE BOARD COMPARTMENT DIMENSIONS IN TABLE board ={ {"tl",1,w20,h40,w40,h20,0}, {"tm",2,w40,h40,w60,h40,0}, {"tr",3,w60,h40,w80,h20,0}, {"ml",4,w20,h60,w40,h40,0}, {"mm",5,w40,h60,w60,h40,0}, {"mr",6,w60,h60,w80,h40,0}, {"bl",7,w20,h80,w40,h60,0}, {"bm",8,w40,h80,w60,h60,0}, {"br",9,w60,h80,w80,h60,0} } -- return scene