From 58b8c95d62d81f6a6de94bec0ca3dca2761a4474 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 13 Jun 2019 18:39:09 +0200 Subject: [PATCH] feat(actor): add *Start() and *End() functions --- gamecore/modules/world/actors/actor2D.lua | 2 ++ gamecore/modules/world/actors/baseactor.lua | 26 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index fb1d2e7..a6613d2 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -193,8 +193,10 @@ end -- Draw the actors. function Actor2D:draw() + self:drawStart() local x, y = math.floor(self.x), math.floor(self.y) self:drawSprite(x, y) + self:drawEnd() end return Actor2D diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index 501c91d..ef9a325 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -106,10 +106,20 @@ end -- UPDATE FUNCTIONS -- Theses functions are activated every steps +function BaseActor:updateStart(dt) + +end + function BaseActor:update(dt) + self:updateStart(dt) self:updateTimers(dt) self:autoMove(dt) self:updateSprite(dt) + self:updateEnd(dt) +end + +function BaseActor:updateEnd(dt) + end function BaseActor:autoMove(dt) @@ -150,6 +160,22 @@ function BaseActor:timerResponse(name) -- here come the timer responses end +-- DRAW FUNCTIONS +-- Draw the actors. + +function BaseActor:drawStart() + +end + +function BaseActor:draw() + self:drawStart() + self:drawEnd() +end + +function BaseActor:drawEnd() + +end + -- SPRITES FUNCTIONS -- Handle the sprite of the actor