mirror of
https://github.com/edubart/otclient.git
synced 2025-12-01 07:36:49 +01:00
rework on graphics.cpp, implement some GFX with lua
This commit is contained in:
26
modules/gfx/gfx.lua
Normal file
26
modules/gfx/gfx.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
GFX = { }
|
||||
|
||||
function GFX.fadeIn(widget, time, elapsed)
|
||||
if not elapsed then elapsed = 0 end
|
||||
if not time then time = 750 end
|
||||
widget.opacity = math.min((255*elapsed)/time, 255)
|
||||
if elapsed < time then
|
||||
scheduleEvent(function()
|
||||
GFX.fadeIn(widget, time, elapsed + 30)
|
||||
end, 30)
|
||||
end
|
||||
end
|
||||
|
||||
function GFX.fadeOut(widget, time, elapsed)
|
||||
if not elapsed then elapsed = 0 end
|
||||
if not time then time = 750 end
|
||||
widget.opacity = (255*(time - elapsed))/time
|
||||
if elapsed < time then
|
||||
scheduleEvent(function()
|
||||
GFX.fadeOut(widget, time, elapsed + 30)
|
||||
end, 30)
|
||||
else
|
||||
widget:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user