Derma_Anim
From Garry's Mod
Derma_Anim( )
Contents |
Description
Creates a new derma animation.
Arguments
string name
Name of the animation to create
Arguments
Panel panel
Panel to run the animation on
Arguments
function func
Returns
A lua metatable containing four methods:
- Run() - Should be called each frame you want the animation to be ran.
- Active() - Returns if the animation is currently active (has not finished and stop has not been called)
- Stop() - Halts the animation at its current progress.
- Start( Length, Data ) - Prepares the animation to be ran for Length seconds. Must be called once before calling Run(). The data parameter will be passed to the func function.
Examples
Example
Applies an easeInQuad easing to the panel to make it glide naturally across the screen.
local function inQuad(fraction, beginning, change) return change * (fraction ^ 2) + beginning end local main = vgui.Create("DFrame") main:SetTitle("Derma_Anim Example") main:SetSize(250, 200) main:SetPos(200) main:MakePopup() local anim = Derma_Anim("EaseInQuad", main, function(pnl, anim, delta, data) pnl:SetPos(inQuad(delta, 200, 600), 300) -- Change the X coordinate from 200 to 200+600 end) anim:Start(2) -- Animate for two seconds main.Think = function(self) if anim:Active() then anim:Run() end end
Output:
Panel naturally glides across the screen from 200 x to 800 x