We create a MarginContainer node (with margins left and right 20, and margins top and bottom 75). We have to set the anchors for bottom and right to 1 so it starts measuring from bottom-right for these two margins.
Then, as the MaginContainer's child, we create a TextureProgress. The under, progress, and over images are shown here:
Under: (Background).
Progress: (this will be clipped by Range.value).
Over: (every pixel is transparent except 4 corners are white - click to verify).
We attach this script to Node:
extends Node
const SPEED = 50
var mc = MarginContainer.new()
var tp
func _ready():
VisualServer.set_default_clear_color(ColorN("white"))
mc.anchor_bottom = 1
mc.anchor_right = 1
mc.margin_left = 20
mc.margin_right = 20
mc.margin_top = 75
mc.margin_bottom = 75
tp = TextureProgress.new()
tp.texture_progress = load("res://progress.png")
tp.texture_over = load("res://over.png")
tp.texture_under = load("res://under.png")
mc.add_child(tp)
add_child(mc)
func _process(delta):
tp.value = fmod(tp.value + SPEED * delta, 100)
The output, with window size of 200,200 and clear color of white, when the progress is about half:
No comments:
Post a Comment