码迷,mamicode.com
首页 > Web开发 > 详细

cocos2d JS 设置字幕循环滚动(背景图滚动亦可)

时间:2017-05-09 21:47:13      阅读:440      评论:0      收藏:0      [点我收藏+]

标签:widget   stop   string   字幕   nod   run   xxxxxx   dap   etc   


 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 设置字幕循环滚动(背景图滚动亦可)

标签:widget   stop   string   字幕   nod   run   xxxxxx   dap   etc   

原文地址:http://www.cnblogs.com/luorende/p/6832627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!