[SOLVED] Linearly tween the current score from 0 upwards over 500ms?

Hello, I am not sure on how to linearly tween a current score from 0 upwards over 500ms. This is done in @Will’s Flappy Bird project. Here is an example, thanks for any help! gif

@Will’s Flappy Bird example is using tween.js.

A UI tween like that leveraging tween.js would probably be done with something along this lines:

function doTweenScore(score) {
  var tweenedScore = { value: 0 };
  var tween = new TWEEN.Tween(tweenedScore)
    .to({ value: score }, 500 )
    .onUpdate(function (obj) {
      this.app.fire('ui:updatescore', Math.round(obj.value);
    })
  .start();
}

and then have your ui subscribe to and update itself in response to that ui:updatescore event.

2 Likes