[SOLVED] How to update label text?

Hi,

I have a label sprite (text: 1000m) and I would like to count it down and update the text of the label. Inside onLoad() I have schedule(countdownFunc, 1); so it calls the countdown function every 1 second. And the countdownFunc is something like this:

countdownFunc: function (dt) {
    this.distanceLabel.setString(parseInt(this.distance -= 1) + "m");
},

where
this.distanceLabel = the node label;
this.distance = 1000;

but I’m getting an Uncaught TypeError: this.distanceLabel.setString is not a function.

Any ideas? Thanks!

@efares

you should use `this.distanceLabel.string = parseInt(this.distance -= 1) + “m”;

2 Likes

I just noticed it in the Quick Start User Manual in the part of updating the score.
Thanks for the reply though!