我对Corona来说是非常。
在我的游戏中,我想要一个包含多个选项的菜单(例如“单人游戏”或“设置”)。当点击任何屏幕消失的选项时,会出现一个新选项。
下一个屏幕(例如,点击“单人游戏”之后)应该有一些文字,如“选择你的角色”,一旦用户点击他们的角色,另一个屏幕淡入等等。
我想知道我所谈论的内容是否被称为场景,如果不是,它们是什么以及它们是如何工作的?
请随意解释,或者如果它太多,请发布指向可理解来源的链接,例如另一个堆栈溢出问题或YouTube视频。
还有一件事是,是否可以让用户滑动屏幕,这会触发将他/她带回不同屏幕/场景的事件?
答案 0 :(得分:2)
以下是了解日冕故事板的链接:Corona storyboard
是的,您可以使用滑动事件触发屏幕分页。为此,请参阅此问题: How to slide pages in Corona SDK
答案 1 :(得分:2)
电晕支持的当前场景管理器是作曲家(故事板已被弃用,将来将无法使用)
日冕场景由composer
每个场景都会响应以下事件:
create
show
hide
destroy
理解场景生命周期的关键,你需要记住create
事件只被称为一次,直到场景被破坏。
事件show
每次调用场景
事件hide
被称为 eveytime ,场景被驳回。
仅当操作系统决定摆脱该场景的内存时才会调用事件destroy
。在您退出应用之前,这可能不会发生。
答案 2 :(得分:1)
是的,所有计划都可以通过场景来完成,适用于组织游戏。
对于每个场景,您都可以在this page结尾处遵循此推荐格式。我会在这个答案结尾处输入它。
一旦你有了场景,你可以用以下方式打电话给他们:
storyboard.gotoScene("name_Of_The_Scene")
并删除场景
storyboard.purgeScene("name_Of_The_Scene")
我认为您可以使用电晕的触摸事件来实现滑动效果(它们非常易于使用)。在我的情况下,我在场景之间使用具有过渡效果的按钮。
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
----------------------------------------------------------------------------------
--
-- NOTE:
--
-- Code outside of listener functions (below) will only be executed once,
-- unless storyboard.removeScene() is called.
--
---------------------------------------------------------------------------------
-- local forward references should go here --
---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
-- Called when the scene's view does not exist:
function scene:createScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- CREATE display objects and add them to 'group' here.
-- Example use-case: Restore 'group' from previously saved state.
-----------------------------------------------------------------------------
end
-- Called BEFORE scene has moved onscreen:
function scene:willEnterScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- This event requires build 2012.782 or later.
-----------------------------------------------------------------------------
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- INSERT code here (e.g. start timers, load audio, start listeners, etc.)
-----------------------------------------------------------------------------
end
-- Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- INSERT code here (e.g. stop timers, remove listeners, unload sounds,etc.)
-----------------------------------------------------------------------------
end
-- Called AFTER scene has finished moving offscreen:
function scene:didExitScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- This event requires build 2012.782 or later.
-----------------------------------------------------------------------------
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- INSERT code here (e.g. remove listeners, widgets, save state, etc.)
-----------------------------------------------------------------------------
end
-- Called if/when overlay scene is displayed via storyboard.showOverlay()
function scene:overlayBegan( event )
local group = self.view
local overlay_name = event.sceneName -- name of the overlay scene
-----------------------------------------------------------------------------
-- This event requires build 2012.797 or later.
-----------------------------------------------------------------------------
end
-- Called if/when overlay scene is hidden/removed via storyboard.hideOverlay()
function scene:overlayEnded( event )
local group = self.view
local overlay_name = event.sceneName -- name of the overlay scene
-----------------------------------------------------------------------------
-- This event requires build 2012.797 or later.
-----------------------------------------------------------------------------
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )
-- "willEnterScene" event is dispatched before scene transition begins
scene:addEventListener( "willEnterScene", scene )
-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )
-- "exitScene" event is dispatched before next scene's transition begins
scene:addEventListener( "exitScene", scene )
-- "didExitScene" event is dispatched after scene has finished transitioning out
scene:addEventListener( "didExitScene", scene )
-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( "destroyScene", scene )
-- "overlayBegan" event is dispatched when an overlay scene is shown
scene:addEventListener( "overlayBegan", scene )
-- "overlayEnded" event is dispatched when an overlay scene is hidden/removed
scene:addEventListener( "overlayEnded", scene )
---------------------------------------------------------------------------------
return scene
答案 3 :(得分:0)
您还可以尝试一个名为Director类的流行第三方场景管理器。它没有内置在Corona中,但是学习起来有点简单。