[CODE]local function AnimateNum(x, tx, time)
if (x == tx) then return tx end
// Define
local fps = (1 / FrameTime())
local scale = math.abs(tx-x) / (fps * time) // Help please? I tried different things like this but I'm stuck.
//Scale
if (x > tx) then
x = ((x - scale) >= tx) and (x - scale) or tx
elseif (x < tx) then
x = ((x + scale) <= tx) and (x + scale) or tx
end
//return
return x
end[/CODE]
So I've been trying to animate my custom GUI stuff, and I'm trying to figure out how to get the amount to scale up or down depending on framerate - the above function is run every frame. Argument x is starting coordinate; Argument xt is the target coordinate; and time is the amount of time it should take to go from x to tx.
Any help is appreciated, thanks.
Are you trying to scale the menu, or just move it?
In that case: [url]http://wiki.garrysmod.com/page/Panel/MoveTo[/url]
I'd like to use the function for both, as it's basically pixels per second I'm trying to get. my GUI elements are drawn using surface; no derma stuff.
so you want it to transition smoothly with MoveTo basically? i think theres a library for that
[editline]28th June 2014[/editline]
yeah i think its called animation. lua file here
C:\Program Files (x86)\Steam\SteamApps\common\GarrysMod\garrysmod\lua\includes\extensions\client\panel\animation.lua
Whole derma animation library that you can reference to.
[URL="https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/lua/includes/extensions/client/panel/animation.lua"]https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/lua/includes/extensions/client/panel/animation.lua[/URL]
Sorry, you need to Log In to post a reply to this thread.