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

asked Feb 15, 2018 in Engine by jarlowrey (611 points)

1 Answer

0 votes
Best answer

It looks like it's _bar.rect_size = size

answered Feb 15, 2018 by jarlowrey (611 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 How to use this Q&A? before posting your first questions.