Adding a Visual Knob to a TextureProgress Node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By StraightUpGruntled

I am currently still working on my long-term project. I would like to know if there is any way to add a dial on top of a progress bar. Similar to the looks of this: Slick Slider Progress Bar with Metal Knob PSD - WeLoveSoLo

Except the know wouldn’t be controlled by the mouse. I just wanna know how to get a knob/dial thing to follow the end of the progress bar.

:bust_in_silhouette: Reply From: picnic

Example. Create a progress bar and a sprite as children of a node then add this to a script for the sprite:

extends Sprite
func _ready():
    position = get_node("../ProgressBar").get_rect().position

func _process(delta):
    # inc the value of the progress bar
    get_node("../ProgressBar").value += 1
    # set the sprite's x position according to value of the bar:
    # you need to scale 'value according in the following line...
position.x = get_node("../ProgressBar").get_rect().position.x + get_node("../ProgressBar").value

As the comment says, you’ll know the x length of the bar so you can calculate a factor to adjust the x position.

Cool. This works with the standard progress bar, but how would I do this with a TextureProgress? Im getting this: Attempt to call function ‘get_rect’ in base ‘null instance’ on a null instance.

StraightUpGruntled | 2018-07-01 00:13

I accidentally made the Sprite the child of the TextureProgress.

StraightUpGruntled | 2018-07-01 00:37