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. 【转】Kubernetes scheduler学习笔记

    简介 Kubernetes是一个强大的编排工具,可以用来很方便的管理许多台机器,为了使机器的资源利用率提高,同时也尽可能的把压力分摊到各个机器上,这个职责就是由scheduler来完成的. Kuber ...

  2. 抓包 127.0.0.1 (loopback) 使用 tcpdump+wireshark

    直接使用 wireshark无法抓取 127.0.0.1环回的数据包,一种解决方法是先传到路由器再返回,但这样可能造成拥塞. Linux 先使用tcpdump抓包并输出为二进制文件,然后wiresha ...

  3. Leetcode(18)-四数之和

    给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满 ...

  4. Ubuntu 18.04 + pip3 install virtualenvwrapper 找不到virtualenvwrapper.sh

    Reference Ubuntu 18.04 只自带python3.6.5, 因此不想装python2了, 但通过apt install 装virtualenvwrapper时发现必须得装python ...

  5. vue watch & arrow function bug

    vue watch & arrow function bug watch: { GeoJSON: function(newValue, oldValue) { log(`\n\n\nGeoJS ...

  6. learning free programming resources form top university of the world

    learning free programming resources form top university of the world Harvard university https://www. ...

  7. Dart 处理json,built_value库

    原文链接 文档 import 'dart:convert'; main() async { // json 转化为 map String jsonStr = ''' [ {"name&quo ...

  8. NGK福利再升级,1万枚VAST限时免费送

    NGK在推出持有算力获得SPC空投活动后,福利再升级,于美国加州时间2021年2月8日下午4点推出新人福利活动,注册NGK成为新会员,即可获得0.2枚VAST奖励. VAST免费福利送活动仅送出1万枚 ...

  9. Java Reference核心原理分析

    本文转载自Java Reference核心原理分析 导语 带着问题,看源码针对性会更强一点.印象会更深刻.并且效果也会更好.所以我先卖个关子,提两个问题(没准下次跳槽时就被问到). 我们可以用Byte ...

  10. 纯CSS实现内容放大缩小效果

    先搭架子 再实现第一个内容 填充更多内容 拆掉border,查看最终效果 html代码 <!-- 服务 --> <div class="service"> ...