Resize FlxBar after creating it



  • Hi, is there a way to resize a FlxBar after you've added it?

    Setting the width and height resize it, but the bar stays the same visible size.



  • Width and height are the size of hitbox. You should use scale.x and scale.y to resize the display. scale takes a float value which indicates the ratio of the scaling to the original size. Doing as below will set the actual size you want:

    var originalWidth:Float = this.width;
    var expectedWidth:Float = 64; // the value you want
    this.scale.x = expectedWidth / originalWidth;
    

    But then you may want to update the hitbox. Because it will stay same as the initial size.

    Edit: You can also use the setGraphicSize() method.



  • Thank you @Gökhan-Solak. That's what I needed.


Log in to reply