I have a “controller” script that runs when the game starts and chooses what first screen to show.
All screens have preload=false
I wish to understand why If in the init method i directly call (MO is monarch lib):
function init(self)
MO.show(CO.SCREEN_MAINMENU)
end
I get a black screen. Error i get is:
ERROR:SCRIPT: /monarch/monarch.lua:567: There is no screen registered with id hash: [MAINMENU]
if i load in response of a message, i get the screen properly shown:
function init(self)
msg.post("#", CO.SCREEN_MAINMENU)
end
function on_message(self, message_id, message, sender)
if message_id == hash(CO.SCREEN_MAINMENU) then
MO.show(CO.SCREEN_MAINMENU)
end
end
It works also if i preload the screen and then show in the callback
local function screenLoaded()
MO.show(CO.SCREEN_MAINMENU)
end
function init(self)
MO.preload(CO.SCREEN_MAINMENU, screenLoaded)
end