电晕中的重新加载屏幕
我正在电晕中开发一个应用程序,我需要一次又一次地重新加载同一屏幕。我不知道如何做到这一点,有人可以用代码向我解释一下吗
I am developing an application in corona where I need to reload the same screen again and again.I don't have any idea as how to do it,Can anybody explain me this with a code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
1) 导演类
2) main.lua
<强>3) myscene.lua
4) reloader.lua
1) director class
2) main.lua
3) myscene.lua
4) reloader.lua
Storyboard API 自构建 2011.678 起可用
这是使用构建 2011.704 的 Storyboard API 的示例,
每次触摸都会重新加载整个场景
Storyboard API is available since build 2011.678
Here's a sample using the storyboard API using build 2011.704
each touch will reload the whole scene
我不太清楚,但我的游戏我使用相同的 lua 文件来更改场景。
myscene.lua
I don't know exactly but my game i use same lua file for changeScene.
myscene.lua
我尝试了另一种对我有用的方法,示例如下 -
步骤 1 - 创建一个对象,例如 - 本地 reloadScene
步骤 2 - 当需要重新加载场景时应用步骤 2 -
重新加载场景=“是”
storyboard.reloadScene("eventsButtonClicked")
步骤3-应用步骤3,当不需要重新加载场景时-
函数场景2a:退出场景(事件)
如果 reloadScene == "YES" 那么
Storyboard.purgeScene("eventsButtonClicked")
重新加载场景=“否”
结尾
结尾
scene2a:addEventListener( "exitScene", scene2a )
I have tried another method which worked for me, example is given below -
Step 1- create a object like - local reloadScene
Step 2- Apply step 2, when reload scene is required -
reloadScene = "YES"
storyboard.reloadScene("eventsButtonClicked")
Step 3- Apply step3, when there is no need of reload scene -
function scene2a:exitScene( event )
if reloadScene == "YES" then
storyboard.purgeScene("eventsButtonClicked")
reloadScene = "NO"
end
end
scene2a:addEventListener( "exitScene", scene2a )
我认为你应该遵循以下步骤:我已经实现了在 Corona 中重新加载/重新启动情节提要场景的步骤。
第 1 步:创建一个函数或代码行,以便从要重新加载或重新启动的故事板类中一次又一次地重新启动/重新加载同一场景。
第 2 步:创建一个 lua 文件:命名为重新加载。下面是 reload.lua 文件的模板。
-- 场景移到屏幕上后立即调用:
-- 当场景即将移出屏幕时调用:
-- 如果场景的视图被移除,则 scene:destroyScene() 将被调用之前调用:
I think you should have to follow this steps: which i have implemented for reloading/restarting the storyboard scene in corona.
Step 1: Create an function or line of code to restart/reload same scene again and again from the storyboard class from where you want to reload or restart.
Step 2: Create an lua file with named reload. Below is the template for reload.lua file.
-- Called immediately after scene has moved onscreen:
-- Called when scene is about to move offscreen:
-- If scene's view is removed, scene:destroyScene() will be called just prior to:
您还可以使用此方法重新加载同一屏幕:
timer.performWithDelay(500, function()director:changeScene("你的场景名称"));
但在调用上述函数之前,您需要从显示组中删除所有对象。
You can also reload the same screen with this method:
timer.performWithDelay(500, function()director:changeScene("your scene name"));
But before calling the above function, you need to remove all the object from the display group.
您可以创建一个重新加载场景,
并调用它来 Roload Any Scene 。
像这样
你的重新加载场景代码就像
You Can Create a Reload Scene ,
And Call that to Roload Any Scene .
Like this
And Your Reload Scene Code like