123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import EventMgr from "../base/EventMgr";
- cc.Class({
- extends: cc.Component,
- properties: {
- maskNode: cc.Node,
- paoNode: cc.Node,
- labPao: cc.RichText,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.node.opacity = 0;
- },
- start () {
- this.startX = 267;
- this.withX = this.maskNode.width;
- this.contentArr = [];
- EventMgr.on('paopao', this.goScroll, this);
- },
- setShowOrHide(bActive){
- this.node.opacity = 0;
- if(bActive){
- if(this.paoNode.getActionByTag(0) && !this.paoNode.getActionByTag(0).isDone()){
- this.node.opacity = 255;
- }
- }
- },
- goScroll(msg){
- this.contentArr.push(msg);
- if(this.paoNode.getActionByTag(0) && !this.paoNode.getActionByTag(0).isDone())
- return;
- let self = this;
- let scrollFun = ()=>{
- let tempTxt = self.contentArr.shift();
- if(tempTxt){
- self.node.opacity = 255;
- self.labPao.string = tempTxt;
- self.paoNode.setPosition(self.startX, 1);
- let distance = self.withX + self.paoNode.width + 20;
- let duration = distance / 100;
- let at = cc.moveBy(duration, cc.v2(-distance, 1));
- let funcMoveEnd = ()=>{
- self.labPao.string = '';
- self.paoNode.setPosition(self.startX, 1);
- scrollFun();
- }
- let seq = cc.sequence(at, cc.callFunc(funcMoveEnd));
- seq.setTag(0);
- self.paoNode.runAction(seq);
- }else{
- self.node.opacity = 0;
- }
- }
- scrollFun();
- },
- onDestroy(){
- EventMgr.off('paopao', this.goScroll, this);
- }
- });
|