cocos 向左滚动公告
2024-08-27 22:53:30
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];
}
}
}
},
最新文章
- solr添加安全设置
- [Java基础]字符串
- poj 1572
- Palindrome_滚动数组&;&;DP
- [LAMP]——mod_security和mod_evasive模块的安装
- 8大排序算法图文讲解 分类: Brush Mode 2014-08-18 11:49 78人阅读 评论(0) 收藏
- Linux CPU亲缘性详解
- SQL生成随机字符串
- C#语言基础原理及优缺点
- MySQL索引篇
- 剑指offer-数组中出现次数超过一半的数字
- LDA &;&; NCA: 降维与度量学习
- python:数据库连接操作入门
- 第十八节、基于传统图像处理的目标检测与识别(HOG+SVM附代码)
- [转载来之雨松:NGUI研究院之为什么打开界面太慢(十三)]
- 比原链(Bytom)先知节点 Windows接入文档
- mysql日期时间函数
- PlainElastic.Net
- 转:sql篇 select from where group by having order by
- beforeunload事件
热门文章
- Linux系统CentOS进入单用户模式和救援模式详解
- python argparse (更新中)
- 基于OpenCV全景拼接(Python)SIFT/SURF
- js swap array
- Github Actions All In One
- Flutter Vignettes
- npx &; yarn &; npm
- MacBook Pro 2019 13 inch &; screen blink
- TypeScript 3.7 RC &; Assertion Functions
- SHON WEBB:太怀念过去的人,往往走不远