Number display

I made 2 widgets for this, a digit block:

digitblock_hierarchy.jpg

and a counter that holds the digit blocks in a horizontal box: (edit: forgot to rename it but *wDigitBlock *= wFieldNumber)

Here the score is added via a button click:

This counter keeps the track of the Total Score, turns it into a string array so we can push individual numbers into digit blocks. Rather than updating all blocks, we only update the ones whose value changed - going from 152 to 172 should only update the middle digit: 5 turns into 7. You may want to add bound checks.

The *Update Display *is a custom event in the Digit Block widget. The *New Digit *keeps track of what needs to the displayed, and we then play an animation:

Above, the *UpdateDigitMidAnim *is a widget animation event that reads New Digit and has the text block display it. This event is triggered in the middle of the animation, as seen below:

The border Clips to Bounds and we update the text block’s value as soon as the widget if fully obscured:

widgetanim.gif

Above, animate text block translation: slide up to -40, linear cut to +40 and interpolate back to 0. The end result:

endresult.gif

There are some bits and bobs here that will surely need improving but the method seems sound enough for this.

1 Like