From 4c71e262bb0de4e6395f4bfc4de9938f935f79e5 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 16 Mar 2019 15:04:55 +0100 Subject: [PATCH] gamecore/scenes: add a wrapper around Scene changing --- gamecore/modules/scenes.lua | 2 +- gamecore/scenemanager.lua | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gamecore/modules/scenes.lua b/gamecore/modules/scenes.lua index cd082e2..60f378c 100644 --- a/gamecore/modules/scenes.lua +++ b/gamecore/modules/scenes.lua @@ -40,7 +40,7 @@ function Scene:new() end function Scene:register() - core.scenemanager.currentScene = self + core.scenemanager:setScene(self) end function Scene:update(dt) diff --git a/gamecore/scenemanager.lua b/gamecore/scenemanager.lua index ad7c9d6..d5e3166 100644 --- a/gamecore/scenemanager.lua +++ b/gamecore/scenemanager.lua @@ -30,6 +30,10 @@ function SceneManager:new(controller) self.currentScene = nil end +function SceneManager:setScene(scene) + self.currentScene = scene +end + function SceneManager:update(dt) if (self.currentScene ~= nil) then local keys = self.controller.input.keys