- Creator 版本: 2.3.3
製作跑馬燈時 每一次載入的訊息 不會自動更新長度
就算更新之後 也會被裁切掉 請問這是甚麼原因呢?
run () {
this.node.getComponent(cc.Label).string = this.marqueData;
this.node.width = this.marqueData.length*25;
this.node.getComponent(cc.Label)._forceUpdateRenderData();
this.marqueeWidth = this.marqueData.length*25;
this.marqueeTime = this.marqueData.length/10*2;
cc.log(this.marqueData.length, this.marqueeWidth, this.marqueeTime, this.marqueeInitPosition, this.node.width)
cc.tween(this.node)
.to(this.marqueeTime, { position: cc.v2(-((this.marqueData.length)*(this.node.getComponent(cc.Label).fontSize)+this.marqueeWidth), this.node.y)})
.call(() => {
this.node.setPosition(cc.v2(this.marqueeInitPosition,this.node.y));
this.run();
})
.start()
},