Вставка в sceneGroup выдвигает на задний план?
Я понятия не имею, как описать эту проблему в заголовке, извините.
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, и я действительно с величайшим разочарованием пытался убедиться, что все удалено в конце сцены. Мне действительно нужно выяснить, как получить вещи в эту группу, не испортив полностью.
Спасибо.
1 ответ
Решение
Я поставил твой код для проверки шаблона сцены. Работает как положено
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' )