Jump to content

Rotating/Moving Progressbar


Karuzo

Recommended Posts

Hey Guys,

so i want to make a smooth progress bar.

But i need a little help with it. I have a picture, but i want to rotate/move the stripes.

I have a dx drawn image, i'm trying to use the rotation arguments but it looks kinda weird.

Is there any possibility to rotate the stripes only around the progressbar ?

Here is a screenshot of my progress bar( i mean the dark green stripes):

qaa49Q0.png

Link to comment

You can create GUI image (1x1 transparent image) or a label without text and then another image of the texture (the green stripes) but set its parent to the transparent image or a label. Then you need to animate the background, to do that, I'd create 2 background images snapped to each other and then move then in 1 direction (left or right). When one image gets to the end then move it to the other side of its neighbor and keep them moving. Once it's all working, extend the size of the parent (label or transparent image).

animated_progressbar.gif

Link to comment

Like i had mentioned in skype, i would use dxDrawImageSection and then animate it using interpolateBetween. And to make it loop after it completes one cycle, i reset the tick count to make it start all over again. This is the first time i have attempted something like this so i might be wrong about this or there might be a much simpler and better alternative. But anyway, it worked for me. Check out the code and give it a try :3

local visibleState = false 
  
function handleRender() 
local now = getTickCount() 
local elapsedTime = now - start 
local duration = 2000 
local progress = elapsedTime / duration 
local a = interpolateBetween (0,0,0,500,0,0, progress, "Linear") 
         
dxDrawImageSection(20,500,200,20,a,0,500,32,"bar.png",180) 
if elapsedTime >= 2000 then start = getTickCount();now = getTickCount() return end 
end 
  
bindKey("m","down", 
function() 
    if visibleState == false then 
     
        start = getTickCount() 
        visibleState = true 
        addEventHandler("onClientRender",root,handleRender) 
  
    else 
        start = getTickCount() 
        visibleState = false 
        removeEventHandler("onClientRender",root,handleRender) 
    end 
end) 
  

The image that i have used:

0a6e565beb52240a8f75a7ac3f5447d2.png

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...