2011-12-07 01:31:55 +01:00
|
|
|
Effects = {}
|
2011-08-14 19:45:25 +02:00
|
|
|
|
2011-12-07 01:31:55 +01:00
|
|
|
function Effects.fadeIn(widget, time, elapsed)
|
2011-08-14 19:45:25 +02:00
|
|
|
if not elapsed then elapsed = 0 end
|
2011-08-15 21:15:49 +02:00
|
|
|
if not time then time = 250 end
|
2012-02-07 07:44:48 +01:00
|
|
|
widget:setOpacity(math.min(elapsed/time, 1))
|
2011-08-14 19:45:25 +02:00
|
|
|
if elapsed < time then
|
|
|
|
scheduleEvent(function()
|
2012-01-04 00:34:35 +01:00
|
|
|
Effects.fadeIn(widget, time, elapsed + 30)
|
2011-08-14 19:45:25 +02:00
|
|
|
end, 30)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-07 01:31:55 +01:00
|
|
|
function Effects.fadeOut(widget, time, elapsed)
|
2011-08-14 19:45:25 +02:00
|
|
|
if not elapsed then elapsed = 0 end
|
2011-08-15 21:15:49 +02:00
|
|
|
if not time then time = 250 end
|
2012-02-07 08:04:03 +01:00
|
|
|
widget:setOpacity(math.max((time - elapsed)/time, 0))
|
2011-08-14 19:45:25 +02:00
|
|
|
if elapsed < time then
|
|
|
|
scheduleEvent(function()
|
2012-01-04 00:34:35 +01:00
|
|
|
Effects.fadeOut(widget, time, elapsed + 30)
|
2011-08-14 19:45:25 +02:00
|
|
|
end, 30)
|
|
|
|
else
|
|
|
|
widget:destroy()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|