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];
}
}
}
},

cocos 向左滚动公告的更多相关文章

  1. [JS]手动实现一个横屏滚动公告js插件

    前言 工作中要用到.在github上找的大部分都是竖屏滚动没办法只能自己手动写. 本来只是想随便实现一下的,结果一时兴起把它弄成了一个简单的小插件,开了个github仓库(希望路过点个星) JS横屏滚 ...

  2. jquery 实现图片无缝向左滚动

    <script type="text/javascript" src="_pub/Script/jquery.js"></script> ...

  3. 滚动公告--jq

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. 【代码笔记】iOS-字体从右向左滚动

    一,效果图. 二,代码. ViewController.m - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup ...

  5. 利用jquery实现向左滚动效果及offset的使用

    昨天和今天做了一个轮播图,它的tab标签不是1,2,3这样的数据表示,而是使用圆圈表示,效果如下:

  6. Taro -- 文字左右滚动公告效果

    文字左右滚动公告效果 设置公告的左移距离,不断减小,当左移距离大于公告长度(即公告已移出屏幕),重新循环. <View className='scroll-wrap'> <View ...

  7. vue 滚动公告

    <!-- 滚动公告 --> <div class="textArr"> <p class="slice-enter-active" ...

  8. HTML-滚动字幕的源代码(可作滚动公告)

    1.字体颜色可变幻的滚动字幕源代码: <DIV style="FILTER: glow(color=#000000 ,strength=1); COLOR: #000000; HEIG ...

  9. javascript 不间断向左滚动图片

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. [Golang]-8 工作池、速率限制、原子计数器、互斥锁

    目录 工作池 速率限制 原子计数器 互斥锁 工作池 在这个例子中,我们将看到如何使用 Go 协程和通道实现一个工作池 . func worker(id int, jobs <-chan int, ...

  2. 网络安全-WEB基础,burpsuite,WEB漏洞

    1. web基础 HTTP: GET POST REQUEST RESPONSE... JDK robots.txt 网页源代码/注释 目录扫描--御剑,dirmap 端口信息--nmap 备份文件- ...

  3. UML类图设计神器 AmaterasUML 的配置及使用

    最近写论文需要用到UML类图,但是自己画又太复杂,干脆找了个插件,是Eclipse的,也有IDEA的,在这里我简单说下Eclipse的插件AmaterasUML 的配置与使用吧. 点击这里下载Amat ...

  4. Java中Class.forName()用法和newInstance()方法详解

    1.Class.forName()主要功能 Class.forName(xxx.xx.xx)返回的是一个类, Class.forName(xxx.xx.xx)的作用是要求JVM查找并加载指定的类,也就 ...

  5. Loss_Function_of_Linear_Classifier_and_Optimization

    Loss_Function_of_Linear_Classifier_and_Optimization Multiclass SVM Loss:    Given an example(xi, yi& ...

  6. vuepress config favicon

    vuepress config favicon .vuepress/public favicons https://vuepress.vuejs.org/guide/assets.html#publi ...

  7. Storybook 最新教程

    Storybook 最新教程 Storybook is the most popular UI component development tool for React, Vue, and Angul ...

  8. ES6 Class vs ES5 constructor function All In One

    ES6 Class vs ES5 constructor function All In One ES6 类 vs ES5 构造函数 https://developer.mozilla.org/en- ...

  9. uname -a

    uname -a Linux shell command https://en.wikipedia.org/wiki/Uname#:~:text=uname $ uname # Darwin $ un ...

  10. macOS 录屏 gif

    macOS 录屏 gif LICEcap bug 授权问题? 如何在 Mac 上录制屏幕 https://support.apple.com/zh-cn/HT208721 Command + Shif ...