将“删除警报屏幕作为显示组”翻译为英文为“Removing Alert screen as display group”。
2015-3-19 7:52:12
收藏:0
阅读:131
评论:1
我又在显示和移除Alert方面遇到了困惑。我使用Displaynew组创建了一个Alert屏幕。我有两个Alert,一个带有按钮(ALert1)以选择操作,而另一个没有按钮(Alert2)以确认操作。问题是,当我调用Alert1并选择使Alert2出现的操作时,我无法同时移除两个Alert。我调用Removealert函数来使两个Alert消失,但我只能删除Alert1。Alert2仍然存在。请帮帮我,谢谢。
以下是代码:
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的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 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
代码本身就有误,你在函数中声明了按钮,但是onRelease函数被声明为local,而且它们的位置在按钮下面。
首先,你应该知道lua是自上而下的方法,所以将代码改为以下方式并尝试:
``` local function removescore(event) scoreDisplayGroup:removeSelf() alertDisplayGroup:removeSelf() end
local function removeAlertScreenScore(event) scoreDisplayGroup:removeSelf()
end
local decidiOK = function(event)
if event.phase=="began" then score.add(punti) score.save() end alertScreen("","分数已保存!") --Alert2
timer.performWithDelay(1000,removescore,1) timeLimit=60 timeLeft.text = "1:00"
end
local decidiCancel = function( event )
if event.phase == "ended" then timer.performWithDelay(100,removeAlertScreenScore,1) end timeLimit=60 timeLeft.text = "1:00" end
function alertScreenScore(title, message) -- Alert1. Alert2 is similar with no buttons and is called alertScreenscore
alertBox=display.newImage("cornice.png") alertBox.x=W alertBox.y=H/1.3
transition.from(alertBox, {time=10,xScale=0.5,yScale=0.6,transition=easing.cutExpo})
titolomessaggio=display.newText(title,0,0,"Arial",100) titolomessaggio:setTextColor(255,255,0,255)
titolomessaggio.xScale=0.5 titolomessaggio.yScale=0.5 titolomessaggio.x=display.contentCenterX titolomessaggio.y=display.contentCenterY-100
testomessaggio=display.newText(message,0,0,"Arial",100) testomessaggio:setTextColor(255,255,0,255) testomessaggio.xScale=0.5 testomessaggio.yScale=0.5 testomessaggio.x=display.contentCenterX testomessaggio.y=display.contentCenterY+10
buttonCancel = widget.newButton { id = "buttonCancel", defaultFile = "buttonbn.png", label = "NO", labelColor = { default = { 0, 0, 0, 255 }, }, font = native.systemFont, fontSize = 30, emboss = true, onEvent = decidiCancel, isEnabled=true }
buttonOK = widget.newButton { id = "buttonOK", defaultFile = "buttonbn.png", label = "YES", labelColor = { default = { 0, 0, 0, 255 }, }, font = native.systemFont, fontSize = 30, emboss = true, onEvent = decidiOK, isEnabled=true } buttonCancel.x=250 buttonCancel.y=620
buttonOK.x=520 buttonOK.y=620
scoreDisplayGroup=display.newGroup() scoreDisplayGroup:insert(alertBox) scoreDisplayGroup:insert(titolomessaggio) scoreDisplayGroup:insert(testomessaggio) scoreDisplayGroup:insert(buttonCancel) scoreDisplayGroup:insert(buttonOK)
end
现在这应该可以工作了,将所有变量声明移到删除分数函数之前。