summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-20 13:27:03 +0200
committerAki <nthirtyone@gmail.com>2017-09-20 13:27:03 +0200
commitf2979320625eceeaadd594ccf6bad6c6b2543aff (patch)
tree2ffdf0063467986cb01d43c4839d5e72e8077714
parent03ccc9890c2b349eb939b0d9fcaa982ead98f0cd (diff)
downloadroflnauts-f2979320625eceeaadd594ccf6bad6c6b2543aff.zip
roflnauts-f2979320625eceeaadd594ccf6bad6c6b2543aff.tar.gz
roflnauts-f2979320625eceeaadd594ccf6bad6c6b2543aff.tar.bz2
Added fadein and fadeout methods to Trap
-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