tibia-client/modules/core_scripts/effects.lua

27 lines
746 B
Lua
Raw Normal View History

2011-12-07 01:31:55 +01:00
Effects = {}
2011-12-07 01:31:55 +01:00
function Effects.fadeIn(widget, time, elapsed)
if not elapsed then elapsed = 0 end
2011-08-15 21:15:49 +02:00
if not time then time = 250 end
2011-08-20 22:30:41 +02:00
widget:setOpacity(math.min((255*elapsed)/time, 255))
if elapsed < time then
scheduleEvent(function()
Effects.fadeIn(widget, time, elapsed + 30)
end, 30)
end
end
2011-12-07 01:31:55 +01:00
function Effects.fadeOut(widget, time, elapsed)
if not elapsed then elapsed = 0 end
2011-08-15 21:15:49 +02:00
if not time then time = 250 end
2011-08-20 22:30:41 +02:00
widget:setOpacity((255*(time - elapsed))/time)
if elapsed < time then
scheduleEvent(function()
Effects.fadeOut(widget, time, elapsed + 30)
end, 30)
else
widget:destroy()
end
end