From 1479839ed0e73415afeac686f5e967afbeaee9f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ritzl?= Date: Thu, 7 Dec 2017 20:48:18 +0100 Subject: [PATCH] Improved the wait the example app is delaying startup until all screens are ready --- example/main.script | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/example/main.script b/example/main.script index 83439c5..d48dfd8 100644 --- a/example/main.script +++ b/example/main.script @@ -1,14 +1,12 @@ local monarch = require "monarch.monarch" function init(self) - self.wait = true 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 -function update(self) - -- Ensure that the initial screen has had enough time to register - if self.wait == true and monarch.screen_exists(hash("menu")) then - self.wait = false +function on_message(self, message_id, message, sender) + if message_id == hash("init_monarch") then monarch.show(hash("menu")) - end -end + end +end \ No newline at end of file