Created
December 30, 2013 16:56
-
-
Save usysrc/8184691 to your computer and use it in GitHub Desktop.
Blinking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local swap = function(a, b, last) | |
return (last == b) and a or b | |
end | |
local period = 0.05 | |
local blinkTimer | |
blinkTimer = function(len) | |
timer.add(period, function() | |
self.alpha = swap(0, 255, self.alpha) | |
if len > 0 then blinkTimer(len-period) else self.alpha = 255 end | |
end) | |
end | |
blinkTimer(0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using love2d + hump