使用电晕SDK重新加载游戏 [英] Reloading a game with corona sdk
问题描述
我正在创建我的第一个iPhone游戏,但无法弄清楚如何重新加载游戏.
I am creating my first iPhone game and cannot figure out how to reload my game.
我正在使用coronaSDK,并尝试使用其composer API.当玩家死后,出现带有再次播放"按钮,当他触摸该按钮时,我会使用composer.gotoScene("reload")
将他定向到一个名为"reload.lua"的场景.
I am using coronaSDK and have tried to use their composer API. When the player dies a button with "play again" appears and when he touches it I direct him to a scene called "reload.lua" with composer.gotoScene("reload")
.
在这个场景中,我有以下代码:
In this scene I have the following code:
function scene:show(event)
local sceneGroup = self.view
local phase = event.phase
if (phase == "will") then
elseif (phase == "did") then
local replay = display.newImage('star1.png', 100, 300)
composer.removeScene("level1")
composer.gotoScene("level1")
end
end
但是,这只会将level1
添加到现有的顶部,而不会删除已使用的顶部.关于如何成功删除level1
或重新加载游戏的任何想法?
However, this only adds level1
on top of the existing one and does not remove the one that has been used. Any ideas on how I could successfully remove level1
or reload my game?
推荐答案
虽然这是基于Composer的哥哥Storyboard的,但这些概念仍然适用于Composer.它说明了尝试重新加载场景时遇到的各种问题,以及如何管理场景的建议:
While this is based on Composer's older brother Storyboard, the concepts still apply to Composer. It explains the various issues with trying to reload scenes, recommendations on how to manage it:
http://coronalabs.com/blog/2013 /08/20/tutorial-reloading-storyboard-scenes/
这篇关于使用电晕SDK重新加载游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!