插入场景组推送到后台?

Inserting in sceneGroup pushes to background?

我不知道如何在标题中描述这个问题,抱歉。

local bBbackground = display.newRoundedRect( Backgroundrectangle.x+(Backgroundrectangle.width/4), Backgroundrectangle.y, 100, 125, 10 )
sceneGroup:insert(bBbackground)
bBbackground.id = "b"
bBbackground.strokeWidth = 2
bBbackground:setFillColor( gradient )
bBbackground:setStrokeColor( 0.2 )

bBmenutext = display.newText( "Bb", 100, 200, "Comic Sans MS", 50)
bBmenutext.x = bBbackground.x
bBmenutext.y = bBbackground.y - aAbackground.height/6
bBmenutext:setFillColor( 0.2 )
bBscoretext = display.newText( "4/8", 100, 200, "Comic Sans MS", 30)
bBscoretext.x = bBbackground.x 
bBscoretext.y = bBbackground.y + bBbackground.height/4
bBscoretext:setFillColor( 0.7 )
sceneGroup:insert(bBmenutext)
sceneGroup:insert(bBscoretext)

如果我去掉 sceneGroup:insert 那么一切都是我想要的:bBmenutext 和 bBscoretext 出现在 bBbackground 前面。然而,事实上,文本组在它后面。我也尝试添加:

bBbackground:toBack()
bBmenutext:toFront()
bBscoretext:toFront()

但无济于事。请问有什么解决办法吗?我对 Corona 还很陌生,真的非常沮丧,一直试图确保在场景结束时删除所有内容。我真的需要弄清楚如何在不完全搞砸的情况下把东西放到那个组里。

谢谢。

我把你的代码scene template给查了。它按预期工作

test.lua

local composer = require( "composer" )

local scene = composer.newScene()


-- -----------------------------------------------------------------------------------
-- Code outside of the scene event functions below will only be executed ONCE unless
-- the scene is removed entirely (not recycled) via "composer.removeScene()"
-- -----------------------------------------------------------------------------------




    -- -----------------------------------------------------------------------------------
    -- Scene event functions
    -- -----------------------------------------------------------------------------------

    -- create()
    function scene:create( event )

        local sceneGroup = self.view
        local bBbackground = display.newRoundedRect( display.contentCenterX, display.contentCenterY, 100, 125, 10 )
        sceneGroup:insert(bBbackground)
        bBbackground.id = "b"
        bBbackground.strokeWidth = 2
        bBbackground:setFillColor( gradient )
        bBbackground:setStrokeColor( 0.2 )

        bBmenutext = display.newText( "Bb", 100, 200, "Comic Sans MS", 50)
        bBmenutext.x = bBbackground.x
        bBmenutext.y = bBbackground.y - 30
        bBmenutext:setFillColor( 0.2 )
        bBscoretext = display.newText( "4/8", 100, 200, "Comic Sans MS", 30)
        bBscoretext.x = bBbackground.x 
        bBscoretext.y = bBbackground.y + bBbackground.height/4
        bBscoretext:setFillColor( 0.7 )
        sceneGroup:insert(bBmenutext)
        sceneGroup:insert(bBscoretext)

    end


    -- show()
    function scene:show( event )

        local sceneGroup = self.view
        local phase = event.phase

        if ( phase == "will" ) then
            -- Code here runs when the scene is still off screen (but is about to come on screen)

        elseif ( phase == "did" ) then
            -- Code here runs when the scene is entirely on screen
    physics.start()
        end
    end


    -- hide()
    function scene:hide( event )

        local sceneGroup = self.view
        local phase = event.phase

        if ( phase == "will" ) then
            -- Code here runs when the scene is on screen (but is about to go off screen)

        elseif ( phase == "did" ) then
            -- Code here runs immediately after the scene goes entirely off screen

        end
    end


    -- destroy()
    function scene:destroy( event )

        local sceneGroup = self.view
        -- Code here runs prior to the removal of scene's view

    end


    -- -----------------------------------------------------------------------------------
    -- Scene event function listeners
    -- -----------------------------------------------------------------------------------
    scene:addEventListener( "create", scene )
    scene:addEventListener( "show", scene )
    scene:addEventListener( "hide", scene )
    scene:addEventListener( "destroy", scene )
    -- -----------------------------------------------------------------------------------

    return scene

main.lua

local composer = require( "composer" )

composer.gotoScene(  'test' )