From df4d264c212ff3288014886df57de21902bbda7d Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 28 May 2019 19:31:42 +0200 Subject: [PATCH] gamecore/scenemanager: let the scene manager handle directly the world --- examples/basic/test_scene2/init.lua | 4 ---- examples/gameplay/moveplayer/init.lua | 4 ++-- examples/gameplay/plateform/init.lua | 4 ++-- gamecore/scenemanager.lua | 6 ++++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/basic/test_scene2/init.lua b/examples/basic/test_scene2/init.lua index 54ce290..447f4ae 100644 --- a/examples/basic/test_scene2/init.lua +++ b/examples/basic/test_scene2/init.lua @@ -51,8 +51,6 @@ function TestScene:update(dt) local i = math.floor(self.i) self.estImpair = (math.floor(i / 2) ~= (i / 2)) - - self.world:update(dt) end function TestScene:mousepressed(x, y) @@ -79,8 +77,6 @@ function TestScene:draw() utils.graphics.resetColor() end - - self.world:draw() end return TestScene diff --git a/examples/gameplay/moveplayer/init.lua b/examples/gameplay/moveplayer/init.lua index bc59962..19e39e8 100644 --- a/examples/gameplay/moveplayer/init.lua +++ b/examples/gameplay/moveplayer/init.lua @@ -37,11 +37,11 @@ function MovePlayer:new() end function MovePlayer:update(dt) - self.world:update(dt) + end function MovePlayer:draw() - self.world:draw() + end return MovePlayer diff --git a/examples/gameplay/plateform/init.lua b/examples/gameplay/plateform/init.lua index 500fc36..4ab87cc 100644 --- a/examples/gameplay/plateform/init.lua +++ b/examples/gameplay/plateform/init.lua @@ -39,11 +39,11 @@ function Plateformer:new() end function Plateformer:update(dt) - self.world:update(dt) + end function Plateformer:draw() - self.world:draw() + end return Plateformer diff --git a/gamecore/scenemanager.lua b/gamecore/scenemanager.lua index 832d40c..4119ab2 100644 --- a/gamecore/scenemanager.lua +++ b/gamecore/scenemanager.lua @@ -67,6 +67,9 @@ function SceneManager:update(dt) self.currentScene:setKeys() self.currentScene.assets:update(dt) self.currentScene.menusystem:update(dt) + if (self.currentScene.world ~= nil) then + self.currentScene.world:update(dt) + end self.currentScene:update(dt) end end @@ -109,6 +112,9 @@ function SceneManager:draw() if (self.currentScene ~= nil) then self.currentScene:draw(dt) self.currentScene.menusystem:draw() + if (self.currentScene.world ~= nil) then + self.currentScene.world:draw() + end end self.controller.screen:cease() end