[英]Can I make a progress bar like where the value is just a little image that travels to the end of progress bar in Godot?
Can I make a progress bar like where the value is just a little image that travels to the end of progress bar in Godot?我可以制作一个进度条,就像值只是一个在 Godot 中移动到进度条末尾的小图像吗?
I was trying to do something like this:我试图做这样的事情:
If anyone who knows some way to do this without framing every possible value, please tell me how.如果有人知道某种方法可以做到这一点,而无需设定所有可能的价值,请告诉我如何。
You could create a new scene, with a line2d as its root, and a sprite (with whatever texture you want) as its child.您可以创建一个新场景,将 line2d 作为其根,将 sprite(具有您想要的任何纹理)作为其子级。 You can set up the line with these properties and could set the image like so .
您可以使用这些属性设置线条,并可以像这样设置图像。 Then all you would need to do is attach a script to the line and increment the x position of the sprite over time.
然后您需要做的就是将脚本附加到该行并随着时间的推移增加精灵的 x position。 I wrote a script example for you here, but depending on your use case you may want to adjust some things or make some of the variables dynamic.
我在这里为您编写了一个脚本示例,但根据您的用例,您可能需要调整一些东西或使一些变量动态化。
extends Line2D
var maxSteps = 100
var count = 0
var step = 1
onready var sprite = get_node("Sprite")
func do_step():
if count < maxSteps:
sprite.global_position.x += step
count += step
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.