实际上我正在使用一个教程,并且该教程中存在一些错误。
有代码:
class "Game"( Graphics )
Game.menuScreen = nil
Game.gameScreen = nil
Game.achScreen = nil
Game.screen = nil
-- main
function Game:main()
-- Create the screens and store their links within the class
Game.menuScreen = MainMenu.new()
Game.gameScreen = GameScreen.new()
Game.achScreen = AchScreen.new()
-- Display menuScreen
Game.showScreen( 'menuScreen' )
end
-- showScreen
function Game.showScreen( name )
-- If a screen is being displayed - remove it from the stage
if Game.screen then
Stage.detach( Game.screen )
Game.screen = nil
end
-- Retrieve a screen link by name
local screen = Game[name]
if not screen then
return nil
end
-- If the screen is found - add it to the stage
Stage.attach( screen )
-- Save the displayed screen
Game.screen = screen
return screen
end
它写给我[string“Game.script”]:11:尝试索引全局'MainMenu'(零值) 我使用的是Dreemchest Composer,这个是tutirul:http://dreemchest.com/doc/en/Game%20menu%20and%20screen.html
实际上我从这段代码中提取了LEVEL选择屏幕,因为我不想在第一场比赛中实现一个关卡选择。
我有一个名为MainMenu的脚本,它的类是MainMenu,Superclass是soMainMenu。
答案 0 :(得分:0)
我知道了,谢谢!
我必须为所有菜单点创建舞台对象才能使其正常工作。这很容易,但教程可能没有写它或我只是不理解它。