From 96b4407ae6410affd0db1e6d6d657d4f65d32235 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 28 Aug 2016 20:41:48 +0200 Subject: No blinking; buttons enabled/disabled --- button.lua | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'button.lua') diff --git a/button.lua b/button.lua index 4b397cf..c5681b2 100644 --- a/button.lua +++ b/button.lua @@ -9,8 +9,7 @@ Button = { sprite, quads, delay = 2, - blinker = 1, - parent + parent, } function Button:new(parent) @@ -39,9 +38,7 @@ function Button:blur() self.focused = false end function Button:active() end -function Button:blink() - self.blinker = 0 -end +function Button:isEnabled() return true end function Button:set(name, func) if type(name) == "string" and type(func) == "function" then self[name] = func @@ -50,13 +47,12 @@ function Button:set(name, func) end function Button:draw(scale) local x,y = self:getPosition() - local blinker = math.floor(self.blinker*4) local quad = self.quads local sprite = self.sprite - if blinker%2 == 0 then + if self:isEnabled() then love.graphics.setColor(255, 255, 255, 255) else - love.graphics.setColor(255, 100, 100, 255) + love.graphics.setColor(140, 140, 140, 255) end love.graphics.draw(sprite, quad.button.normal, x*scale, y*scale, 0, scale, scale) if self.focused then @@ -71,12 +67,9 @@ function Button:update(dt) if self.delay > Button.delay then -- Button.delay is initial self.delay = self.delay - Button.delay end - if self.blinker < Button.blinker then -- Button.blink is initial - self.blinker = self.blinker + dt - end end function Button:controlpressed(set, action, key) - if action == "attack" and self.focused then + if action == "attack" and self.focused and self:isEnabled() then self:active() end end -- cgit v1.1