3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 10:27:49 +02:00

Improved the wait the example app is delaying startup until all screens are ready

This commit is contained in:
Björn Ritzl 2017-12-07 20:48:18 +01:00
parent 0c45c3007a
commit 1479839ed0

View File

@ -1,14 +1,12 @@
local monarch = require "monarch.monarch" local monarch = require "monarch.monarch"
function init(self) function init(self)
self.wait = true
msg.post("@render:/", "clear_color", { color = vmath.vector4(0.4, 0.6, 0.8,1.0) }) msg.post("@render:/", "clear_color", { color = vmath.vector4(0.4, 0.6, 0.8,1.0) })
msg.post("#", "init_monarch") -- wait until init() has been called for all screen.script instances
end end
function update(self) function on_message(self, message_id, message, sender)
-- Ensure that the initial screen has had enough time to register if message_id == hash("init_monarch") then
if self.wait == true and monarch.screen_exists(hash("menu")) then
self.wait = false
monarch.show(hash("menu")) monarch.show(hash("menu"))
end end
end end