zoukankan      html  css  js  c++  java
  • cocos 向左滚动公告

     
    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(' ')){
    data[0].content = data[0].content.replace(/[ ]/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];
    }
    }
    }
    },
  • 相关阅读:
    Keras实例教程(2)
    Keras实例教程(1)
    tf.nn.l2_loss()的用法
    在tensorflow中使用batch normalization
    Tensorflow的LRN是怎么做的
    CNN卷积中多通道卷积的参数问题
    caffe学习网站
    交叉熵反向求导计算过程
    矩阵求导
    循环神经网络(RNN)模型与前向反向传播算法
  • 原文地址:https://www.cnblogs.com/min77/p/11451337.html
Copyright © 2011-2022 走看看