电晕显示叠加不会出现第二次



我的showOverlay函数有问题。在我的场景2中,我有一个按钮点击,显示'composer.showOverlay()',它确实显示了覆盖,但当我第二次打开它时,用'hideOverlay()'关闭后,它什么也不做。我首先要回到scene1,然后再回到scene2,这样才能再次显示叠加。我不知道我的代码哪里错了,我谷歌了一下,所有的代码都和我的相似。

代码如下:

scene2。lua, showOverlay()的按钮

local function reminderBtn( event )
-- OVERLAY SCENE
local sceneOverlayOptions = 
{
    time = 100,
    effect = "slideLeft",
    -- PASS PARAM VAR TO NEXT SCENE
    params = { result = "Overlay Example" },
    isModal = true
}
-- SHOW OVERLAY SCENE AFTER PRESS ON reminderBtn
composer.showOverlay( "sceneOverlay", sceneOverlayOptions)
return true
end
local tabButtons = 
{
    {
        id = "tab1",
        width = 32, 
        height = 32,
        defaultFile = "images/Alarm_Clock-32.png",
        overFile = "images/Alarm_Clock-32.png",
        labelYOffset = -1,
        onPress = reminderBtn,
    },
    {
        id = "tab2",
        width = 32, 
        height = 32,
        defaultFile = "images/Checked-32.png",
        overFile = "images/Checked-32.png",  
        labelYOffset = -1,          
        onPress = homeBtn,
    },
    {
        id = "tab3",
        width = 32, 
        height = 32,
        defaultFile = "images/Image_File-32.png",
        overFile = "images/Image_File-32.png", 
        labelYOffset = -1,           
        onPress = test,
    }
}
local tabBar = widget.newTabBar
{
    top = display.contentHeight - 40,
    width = display.contentWidth,
    buttons = tabButtons,
}
sceneGroup:insert( tabBar )

sceneOverlay.lua

-- FUNCTION FOR WHENEVER hideOverlayBtn IS PRESSED
local function goBack( event )
if (event.phase == "ended") then    
    composer.hideOverlay( "slideRight", 250)
    return true
end
end
-- "scene:create()"
function scene:create( event )
local sceneGroup = self.view
-- GET PARAM VAR FOM SCENE 2
local params = event.params.result
--CREATE A RECTANGLE (SCREEN OVERLAY)
local overlayRectangle = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
overlayRectangle.x = display.contentWidth / 2
overlayRectangle.y = display.contentHeight / 2
overlayRectangle:setFillColor( 0.8, 0.80, 0.8)
local hideOverlayBtn = widget.newButton
{
    left = 100,
    top = 200,
    id = "button1",
    label = "Back",
    onEvent = goBack
}
hideOverlayBtn.x = display.contentWidth / 2
hideOverlayBtn.y = display.contentHeight / 2
sceneGroup:insert( overlayRectangle )
sceneGroup:insert( hideOverlayBtn )

我想那是因为tabButton已经被选中了。你不能连续两次使用tab键。尝试使用sceneOverlay按钮。并保持tabButtons在场景之间移动…

相关内容

  • 没有找到相关文章

最新更新