spriteFrame updating

Hi I am trying to use the spriteFrame to achieve a progress bar effect.

Basically I have a sprite in a node. Depending on the percent of progress is how much of that sprite I want ti display.

eg 0% = 0 width, 50% shows 50% of image.

Here is the code which is running in the update.

    var sprite = this.singleGreenBarNode.getComponent(cc.Sprite);
    var rect = sprite.spriteFrame.getRect();
    rect.width = this.greenProgress
    sprite.spriteFrame.setRect( rect );

It seems to update once but never again. Whats going wrong?

OK Figured out a better way of doing it :slight_smile:

Created an Empty node and added a Mask to it.
Placed sprite inside empty node.
Change size of empty node depending on size of sprite I want to show.