From f30bbc75099158501375013dfd1e5a5b63bcb584 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 8 Apr 2019 19:40:27 +0200 Subject: [PATCH] modules/world: better separation of init functions --- gamecore/modules/world/actors/actor2D.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 1a351e2..2c8cb4f 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -1,15 +1,26 @@ local Actor2D = Object:extend() function Actor2D:new(world, type, x, y, w, h) + self.type = type or "" + + self:setManagers(world) + self:initPhysics(x, y, w, h) + + self:initKeys() + self:register() +end + +function Actor2D:setManagers(world) self.world = world + self.scene = world.scene + self.obj = world.obj +end + +function Actor2D:initPhysics(x, y, w, h) self.x = x or 0 self.y = y or 0 self.w = w or 0 self.h = h or 0 - self.type = type or "" - - self:initKeys() - self:register() end function Actor2D:initKeys()