cocos2d JS 設定字幕迴圈滾動(背景圖滾動亦可)

來源:互聯網
上載者:User

標籤: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 設定字幕迴圈滾動(背景圖滾動亦可)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.