cocos2d JS 设置字幕循环滚动(背景图滚动亦可)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cocos2d JS 设置字幕循环滚动(背景图滚动亦可)相关的知识,希望对你有一定的参考价值。
1 var dong = ccs.load("res/Login.json"); 2 this.addChild(dong.node); 3 4 this.cShamNotice = ccui.helper.seekWidgetByName(dong.node,"cShamNotice"); //字幕背景框 5 this.cShamNotice.setVisible(false); 6 var str = "请各位玩家文明娱乐,远离赌博。如发现有赌博行为,将封停账号,并向xxxxx举报!诚招各级玩家代理,微信:xxxxxx"; 7 this.tfShamNotice = ccui.helper.seekWidgetByName(dong.node,"tfShamNotice");//文本txt 8 this.tfShamNotice.setFontName(I18N.defaultFont); 9 this.tfShamNotice.ignoreContentAdaptWithSize(true); 10 this.tfShamNotice.setString(str); 11 12 this.runShamNotice(true); 13 14 15 16 //调用此方法计算坐标即可 17 runShamNotice : function(bool) { 18 if(bool) { 19 this.cShamNotice.setVisible(true); 20 21 var cWidth = this.cShamNotice.getContentSize().width; 22 var cHeight = this.cShamNotice.getContentSize().height; 23 var tfWidth = this.tfShamNotice.getContentSize().width; 24 25 this.tfShamNotice.setPositionX(cWidth); 26 27 var runAct = cc.sequence(cc.moveTo(20, -tfWidth, cHeight / 2), cc.callFunc(function() { 28 this.tfShamNotice.setPositionX(cWidth); 29 }, this), cc.delayTime(0.5)); 30 31 this.tfShamNotice.stopAllActions(); 32 this.tfShamNotice.runAction(cc.repeatForever(runAct)); 33 }else { 34 this.cShamNotice.setVisible(false); 35 36 this.tfShamNotice.stopAllActions(); 37 } 38 }
以上是关于cocos2d JS 设置字幕循环滚动(背景图滚动亦可)的主要内容,如果未能解决你的问题,请参考以下文章