DarkByte Posted August 4, 2016 Share 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? Link to comment
Bonus Posted August 4, 2016 Share 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 ) Link to comment
DarkByte Posted August 5, 2016 Author Share 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") Link to comment
Moderators IIYAMA Posted August 5, 2016 Moderators Share Posted August 5, 2016 1 - Progress = invert Link to comment
DarkByte Posted August 5, 2016 Author Share Posted August 5, 2016 It keeps decreasing, not stopping at the needed value. Link to comment
Bonus Posted August 5, 2016 Share 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 ) Link to comment
DarkByte Posted August 5, 2016 Author Share Posted August 5, 2016 I was saying that to IIYAMA Link to comment
Moderators IIYAMA Posted August 5, 2016 Moderators Share Posted August 5, 2016 if progress <= 0 then progress = 0 -- + stop it. end Link to comment
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