From f2979320625eceeaadd594ccf6bad6c6b2543aff Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 20 Sep 2017 13:27:03 +0200 Subject: Added fadein and fadeout methods to Trap --- not/Trap.lua | 17 +++++++++++++++++ not/World.lua | 7 ++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/not/Trap.lua b/not/Trap.lua index 25eeb0b..2ebb4d2 100644 --- a/not/Trap.lua +++ b/not/Trap.lua @@ -38,6 +38,23 @@ function Trap:new (direction, x, y, world, imagePath) self.mirror = mirror end +function Trap:fadeIn () + self.hidden = false + self:setBodyActive(true) + if self.animations.fadein then + self:setAnimation("fadein") + end +end + +function Trap:fadeOut () + self:setBodyActive(false) + if self.animations.fadeout then + self:setAnimation("fadeout") + else + self.hidden = true + end +end + function Trap:getHorizontalMirror () return self.mirror end diff --git a/not/World.lua b/not/World.lua index 3eec9fd..9a37965 100644 --- a/not/World.lua +++ b/not/World.lua @@ -92,11 +92,8 @@ function createFlame (self, x, y, direction, timerIn, timerOut) trap.layer = self.layers.platforms - timerIn:register(trap.setBodyActive, trap, true) - timerIn:register(trap.setAnimation, trap, "fadein") - timerIn:register(function (self) trap.hidden = false end, trap) - timerOut:register(trap.setBodyActive, trap, false) - timerOut:register(trap.setAnimation, trap, "fadeout") + timerIn:register(trap.fadeIn, trap) + timerOut:register(trap.fadeOut, trap) self:insertEntity(trap) end -- cgit v1.1