summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--not/Trap.lua17
-rw-r--r--not/World.lua7
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