BattyMilk Posted April 9, 2015 Share Posted April 9, 2015 I have a BitmapText object displaying a numeric score. i.e "Score: 50". Is there any way I can affect the score value with a tween when the score increases so that the number rolls up to to the new value, rather than just changing the text in one hit with: this.scoreLabel.text = "Score: 100"; I know that I could achieve this with the update function with checks for a flag that I set when the score goes up to increase the score until the desired value is reached, however it seems a little unnecessary and wasteful to be checking for this flag every cycle of the update function. Does anyone have any bright ideas how I could achieve this?Ta Link to comment Share on other sites More sharing options...
BattyMilk Posted April 9, 2015 Author Share Posted April 9, 2015 To prevent the build up of tumbleweeds, here's how I achieved this if anyone comes across a similar issue: DecoratorBonusScene.prototype.tweenScore = function(obj, startValue, endValue, time) { var scoreValue = {}; scoreValue.score = startValue; var scoreTween = this.game.add.tween(scoreValue).to({score: endValue}, time); scoreTween.onUpdateCallback(function() { obj.text = "Score: "+scoreValue.score; }); scoreTween.start(); } drhayes 1 Link to comment Share on other sites More sharing options...
Recommended Posts