I was making a health meter today, and I think I may have stumbled onto a bug. It looks like UIMeter will try and show an animation frame that is outside the bounds of the animSettings array.
In my case, I have created a UIMeterHealth class that extends ig.UIMeter. My meter references a sprite sheet that contains 12 images, each of 32x32px (3 across and 4 down), and has animSettings like so...
On the UIMeter.draw method (line 374), it calculates the current frame based on the length of the animation sequence and this.value. The value can range from 0 to 1, inclusive. Whenever it is anything from 0 to 12 - 1 = 11, everything is fine. When it nears the max health of the player, however, this.value becomes 1, and frame gets set to 12, which is outside of the bounds of the array.
Adding this line seemed to fix it for me. Let me know if a PR would help and I can send one.
if (frame == this.currentAnim.sequence.length) frame--;
I was making a health meter today, and I think I may have stumbled onto a bug. It looks like
UIMeter
will try and show an animation frame that is outside the bounds of theanimSettings
array.In my case, I have created a
UIMeterHealth
class that extendsig.UIMeter
. My meter references a sprite sheet that contains 12 images, each of 32x32px (3 across and 4 down), and hasanimSettings
like so...On the
UIMeter.draw
method (line 374), it calculates the current frame based on the length of the animation sequence andthis.value
. The value can range from 0 to 1, inclusive. Whenever it is anything from 0 to 12 - 1 = 11, everything is fine. When it nears the max health of the player, however,this.value
becomes 1, andframe
gets set to 12, which is outside of the bounds of the array.Adding this line seemed to fix it for me. Let me know if a PR would help and I can send one.