I have two game modes in my game. They both use the same levelSelect.lua file. However, on the second one, a random white square appears at the top of the screen and I have no idea why. Here is my scene:create:
function scene:create(event) playgroundMode = event.params.playgroundMode local gameSettings = loadsave.loadTable("gameSettings.json") if gameSettings.adsEnabled == true and system.getInfo("platform") == "android" then appodeal.show("banner", {yAlign = "top"}) elseif gameSettings.adsEnabled == true and system.getInfo("platform") == "ios" then appodeal.show("banner", {yAlign = "bottom"}) end local sceneGroup = self.view local buttonsGroup = display.newGroup() local scrollView = widget.newScrollView( { x = display.contentCenterX, y = display.contentCenterY, width = display.actualContentWidth, height = display.actualContentHeight, scrollWidth = display.actualContentWidth, scrollHeight = display.actualContentHeight, horizontalScrollDisabled = true, isBounceEnabled = false, backgroundColor = gameSettings.background, } ) levelMarginY = display.actualContentHeight / 6 --make sure to edit the following if statement if u change this levelMarginX = display.actualContentWidth / 4 --change the x of the button code if u change this --grid position local xPos = 1 if playgroundMode == false then for i = 1, composer.getVariable("levelCount") do local button = widget.newButton({ id = i, label = i, shape = "rect", width = 50, height = 50, fontSize = 30, x = xPos \* levelMarginX - (display.actualContentWidth / 8), y = levelMarginY, strokeWidth = 2, font = gameSettings.defaultFont, strokeColor = { default = gameSettings.buttonStroke, over = gameSettings.buttonOverStroke }, fillColor = { default = gameSettings.fill, over = gameSettings.fill }, onRelease = onLevelButtonRelease, labelColor = { default = gameSettings.buttonStroke, over = gameSettings.buttonOverStroke} , }) if i \> gameSettings.levelsComplete + 1 then button.alpha = .5 else button.alpha = 1 end if i == gameSettings.levelsComplete + 1 then button:setStrokeColor(colors.colors.yellow) end xPos = xPos + 1 if (xPos \> 4) then --starts new row levelMarginY = levelMarginY + (display.actualContentHeight / 6) xPos = 1 end buttonsGroup:insert(button) scrollView:insert(buttonsGroup) end elseif playgroundMode == true then for i = 1, composer.getVariable("playgroundCount") do local button = widget.newButton({ id = i, label = "P"..i, shape = "rect", width = 50, height = 50, fontSize = 30, x = xPos \* levelMarginX - (display.actualContentWidth / 8), y = levelMarginY, strokeWidth = 2, font = gameSettings.defaultFont, strokeColor = { default = gameSettings.buttonStroke, over = gameSettings.buttonOverStroke }, fillColor = { default = gameSettings.fill, over = gameSettings.fill }, onRelease = onLevelButtonRelease, labelColor = { default = gameSettings.buttonStroke, over = gameSettings.buttonOverStroke} , }) xPos = xPos + 1 if (xPos \> 4) then --starts new row levelMarginY = levelMarginY + (display.actualContentHeight / 6) xPos = 1 end buttonsGroup:insert(button) scrollView:insert(buttonsGroup) end end local padding if system.getInfo("platform") == "ios" then padding = display.newRect(display.contentCenterX, buttonsGroup.height \* 1.25, 20, 30) else padding = display.newRect(display.contentCenterX, buttonsGroup.height \* 1.25, 20, 20) end padding.alpha = 1 scrollView:insert(padding) sceneGroup:insert(scrollView) end
Any idea what’s causing the issue? Thanks in advance!