我不知道如何在标题中描述这个问题,抱歉。
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来说很新,而且最令人沮丧的是一直试图确保在场景结束时删除所有内容。我真的需要弄清楚如何在没有完全弄乱的情况下把事情搞定。
谢谢。
答案 0 :(得分:1)
我将您的代码设为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' )