DarkByte Posted August 4, 2016 Posted August 4, 2016 Hello, I'm using interpolateBetween in my hud, it's working like a loading bar forward but it doesn't use the animation backwards, help?
Bonus Posted August 4, 2016 Posted August 4, 2016 Let the fProgress go from 1 to 0. Like that: local animcoming = true local progstart = 0 local function drawThatAnim ( ) local progress = 0 if animcoming then progress = (getTickCount()-progstart)/5000 if progress >= 2 then animcoming = false progstart = getTickCount()+1050 end else progress = ( progstart - getTickCount() ) / 5000 end local x, y = interpolateBetween ( 0, 0, 0, 1000, 1000, 0, progress, "Linear" ) dxDrawRectangle ( x, y, 10, 10, tocolor ( 255, 0, 0 ), true ) end function stopAnimDraw ( ) removeEventHandler ( "onClientRender", root, drawThatAnim ) end addCommandHandler ( "startanim", function ( ) animcoming = true progstart = getTickCount() addEventHandler ( "onClientRender", root, drawThatAnim ) end )
DarkByte Posted August 5, 2016 Author Posted August 5, 2016 I've made this, it won't go backwards using animation only forward. local lenghtHPC = interpolateBetween(0,0,0,lenghtHPC,0,0, (now - start) / ((start + 5000) - start), "OutQuad")
DarkByte Posted August 5, 2016 Author Posted August 5, 2016 It keeps decreasing, not stopping at the needed value.
Bonus Posted August 5, 2016 Posted August 5, 2016 Oh, I forgot to use stopAnimDraw: local animcoming = true local progstart = 0 local function drawThatAnim ( ) local progress = 0 if animcoming then progress = (getTickCount()-progstart)/5000 if progress >= 2 then animcoming = false progstart = getTickCount()+1050 end else progress = ( progstart - getTickCount() ) / 5000 if progress >= 1 then -- NEW stopAnimDraw() -- NEW return -- NEW end -- NEW end local x, y = interpolateBetween ( 0, 0, 0, 1000, 1000, 0, progress, "Linear" ) dxDrawRectangle ( x, y, 10, 10, tocolor ( 255, 0, 0 ), true ) end function stopAnimDraw ( ) removeEventHandler ( "onClientRender", root, drawThatAnim ) end addCommandHandler ( "startanim", function ( ) animcoming = true progstart = getTickCount() addEventHandler ( "onClientRender", root, drawThatAnim ) end )
Moderators IIYAMA Posted August 5, 2016 Moderators Posted August 5, 2016 if progress <= 0 then progress = 0 -- + stop it. end
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now