properties:{
lblNotice:[cc.Node],
speed:1,
curtext:null
},
start (){
this.getNotice();
},
getNotice(){
cc.abc.HttpUtils.httpGet(cc.abc.Global.Reqeust.getNotice,(ret)=>{
if (ret && ret.returncode == "Y" && ret.data){
let data = ret.data.notices; //取集合第一条
cc.fj.Parameter.homeNotice = ret.data.notices;
if (data[0].content.indexOf('\n')){
data[0].content = data[0].content.replace(/[\n]/g, " ") + " ";
}
this.lblNotice[0].getComponent("MyLabel").string=data[0].content ;
this.lblNotice[1].getComponent("MyLabel").string=data[0].content ;
this.scheduleOnce(function() {
this.flag = true;
this.lblNotice[1].x = this.lblNotice[0].x+this.lblNotice[0].width+150;
}, 0.1);
this.curtext = this.lblNotice[0];
}
});
},
update (dt) {
let s = dt * this.speed + 2;
let width = this.lblNotice[0].width;
if(this.flag){
this.lblNotice[0].x -= s;
this.lblNotice[1].x -= s;
if (this.curtext.x <= -width) {
if(this.curtext == this.lblNotice[1]) {
this.lblNotice[1].x = this.lblNotice[0].x+this.lblNotice[0].width+150;
this.curtext = this.lblNotice[0];
}
else {
this.lblNotice[0].x = this.lblNotice[1].x+this.lblNotice[1].width+150;
this.curtext = this.lblNotice[1];
}
}
}
},