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