将 sceneGroup 插入场景后,如何将其置于后台?
2017-4-18 11:4:44
收藏:0
阅读:102
评论:1
很抱歉,我不知道如何在标题中描述这个问题。
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 的后面。我还尝试了添加以下代码:
bBbackground:toBack()
bBmenutext:toFront()
bBscoretext:toFront()
但是都没有起到作用。请问有什么解决方案吗?我对 Corona 还比较陌生,而最大的挫折就是要确保在场景结束时删除所有内容。我真的需要想办法把这些元素放入到那个组中,但是又不会完全搞砸。
谢谢。
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

我使用了你的代码 场景模板 进行了检查,它能够如预期地工作。
test.lua
local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------- -- 场景事件函数下方的代码只会被执行一次,除非场景通过 "composer.removeScene()" 被完全移除(而不是回收)。 -- ----------------------------------------------------------------------------------- -- ----------------------------------------------------------------------------------- -- 场景事件函数 -- ----------------------------------------------------------------------------------- -- scene: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 ) local bBmenutext = display.newText( "Bb", 100, 200, "Comic Sans MS", 50) bBmenutext.x = bBbackground.x bBmenutext.y = bBbackground.y - 30 bBmenutext:setFillColor( 0.2 ) local 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 -- scene:show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- 当场景还未完全呈现在屏幕上时调用此处代码(场景切换动画开始之前) elseif ( phase == "did" ) then -- 当场景完全呈现在屏幕上时调用此处代码 physics.start() end end -- scene:hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- 当场景即将从屏幕上卸载时调用此处代码(场景切换动画即将开始) elseif ( phase == "did" ) then -- 当场景完全从屏幕上卸载之后调用此处代码 end end -- scene:destroy() function scene:destroy( event ) local sceneGroup = self.view -- 此处代码在场景的视图被移除之前运行。 end -- ----------------------------------------------------------------------------------- -- 将画面事件函数添加到场景事件监听器 -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scenemain.lua
local composer = require( "composer" ) composer.gotoScene( 'test' )