Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Random white sqaure when creating a scene
Started by fwcarlitos Apr 28 2018 05:03 AM

1 reply to this topic
composer scene

Best Answer fwcarlitos , 28 April 2018 - 06:18 PM

I fixed the issue. It was with the padding code at the bottom.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

fwcarlitos

[GLOBAL: userInfoPane.html]
fwcarlitos
  • Enthusiast

  • 56 posts
  • Corona SDK

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!



[TOPIC: post.html]
#2

fwcarlitos

[GLOBAL: userInfoPane.html]
fwcarlitos
  • Enthusiast

  • 56 posts
  • Corona SDK

  Best Answer

I fixed the issue. It was with the padding code at the bottom.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: composer, scene