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)
|
2012-03-23 14:48:05 +01:00
|
|
|
if not elapsed then elapsed = 0 end
|
|
|
|
if not time then time = 250 end
|
|
|
|
widget:setOpacity(math.min(elapsed/time, 1))
|
|
|
|
if elapsed < time then
|
|
|
|
removeEvent(widget.fadeEvent)
|
|
|
|
widget.fadeEvent = scheduleEvent(function()
|
|
|
|
Effects.fadeIn(widget, time, elapsed + 30)
|
|
|
|
end, 30)
|
|
|
|
else
|
|
|
|
widget.fadeEvent = nil
|
|
|
|
end
|
2011-08-14 19:45:25 +02:00
|
|
|
end
|
|
|
|
|
2011-12-07 01:31:55 +01:00
|
|
|
function Effects.fadeOut(widget, time, elapsed)
|
2012-03-23 14:48:05 +01:00
|
|
|
if not elapsed then elapsed = 0 end
|
|
|
|
if not time then time = 250 end
|
|
|
|
widget:setOpacity(math.max((time - elapsed)/time, 0))
|
|
|
|
if elapsed < time then
|
|
|
|
removeEvent(widget.fadeEvent)
|
|
|
|
widget.fadeEvent = scheduleEvent(function()
|
|
|
|
Effects.fadeOut(widget, time, elapsed + 30)
|
|
|
|
end, 30)
|
|
|
|
else
|
|
|
|
widget.fadeEvent = nil
|
|
|
|
widget:destroy()
|
|
|
|
end
|
2011-08-14 19:45:25 +02:00
|
|
|
end
|
|
|
|
|
2012-03-23 14:48:05 +01:00
|
|
|
function Effects.cancelFade(widget)
|
|
|
|
removeEvent(widget.fadeEvent)
|
|
|
|
end
|