我的问题是这样的,为Label.string赋值。但是赋不上,界面不刷新。Log打印的是有值的。
export default class DoubleCoinPage extends cc.Component {
@property(cc.Node)
close: cc.Node = null;
@property(cc.Node)
watchVideo: cc.Node = null;
@property(cc.Node)
timeLabel: cc.Label = null;
public Show() {
this.close.addComponent(TouchComp).SetTouchEndCallback(this.onCloseClicked.bind(this));
this.watchVideo.addComponent(TouchComp).SetTouchEndCallback(this.onWatchVideoClicked.bind(this));
NotificationCenter.Instance.on(NotificationType.DoubleCoinLeftTimeChange, this.onLeftTimeChange, this);
}
private onCloseClicked(event: cc.Event.EventTouch) {
NotificationCenter.Instance.off(NotificationType.DoubleCoinLeftTimeChange, this.onLeftTimeChange, this);
PageManager.Instance.HideDoubleCoinPage();
}
private onWatchVideoClicked(event: cc.Event.EventTouch) {
//TODO:在视频播放完成后的回调中增加时间
DataManager.Instance.DoubleCoinLeftTime = DataManager.Instance.DoubleCoinLeftTime + 300;
}
private onLeftTimeChange(value: number) {
let str = NumberExt.ToHMS(value);
Debug.Error("onLeftTimeChange:" + value + ", str:" + str);
this.timeLabel.string = str;
Debug.Error("@@@:" + this.timeLabel.string);
}
}
如上代码,log打印了str字符串值是对的。打印的this.timeLabel.string的值也是对的。但是在UI层,并没有刷新。

