This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I would like to set a progress bar to the size of a sprite's width. I had this working in 2.1, but don't see how to do it in 3.0. Any ideas?

func _resize_my_bar():
    var sprite = _my_entity.get_node("RigidBody2D/CollisionPolygon2D/Sprite")
    var parent_size = sprite.get_item_rect().size
    #x and y are reversed on the bodies, so reverse them here too
    var size = Vector2(max(parent_size.y,50), bar_height)
    var pos = Vector2(-size.x/2, -parent_size.x/2 - bar_height - bar_margin)

I know how to get sprite size: $KinematicBody2D/Sprite.texture.get_size(), but not how to change Progress Bar size

in Engine by (700 points)

1 Answer

0 votes
Best answer

It looks like it's _bar.rect_size = size

by (700 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.