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\n\n@ccclass\n@menu(\"自定义UI组件/Typewriter\")\nexport default class Typewriter extends cc.Component {\n typerTimer: any = null; // 计时器Id\n private showingString: string = \"\";\n private showingNode: any;\n private finishCallFunc: Function | undefined;\n\n onLoad() {\n }\n\n clearParam() {\n this.showingString = \"\";\n this.showingNode = undefined;\n this.finishCallFunc = undefined;\n }\n\n onDisable() {\n this.clearParam();\n this.clearTimer();\n }\n\n onDestroy() {\n this.clearParam();\n this.clearTimer();\n }\n\n clearTimer() {\n // Destroy前确保定时器关闭\n this.typerTimer && clearInterval(this.typerTimer);\n }\n\n showLabelTyper(label: cc.Label, str: string) {\n label.string = '';\n this.showingString = str;\n this.showingNode = label;\n this.makeLaberTyper(label, str);\n }\n\n showRichTextTyper(richText: cc.RichText, str: string, finishCallFunc?: Function, showIngCallFunc?: Function, playSpeed: number = 1) {\n richText.string = '';\n this.showingString = str;\n this.showingNode = richText;\n this.finishCallFunc = finishCallFunc;\n this._makeRichTextTyper(richText, str, finishCallFunc, showIngCallFunc, playSpeed);\n }\n\n stopTyperShowString() {\n this.clearTimer();\n this.showingNode.string = this.showingString;\n if (this.finishCallFunc) {\n this.finishCallFunc();\n }\n this.clearParam();\n }\n\n getShowingString() {\n return this.showingString;\n }\n\n makeLaberTyper(label: cc.Label, str: string) {\n let charArr = str.split('');\n let charIdx = 0;\n\n this.clearTimer()\n this.typerTimer = setInterval(() => {\n if (charIdx >= charArr.length) {\n this.clearTimer();\n this.showingString = \"\";\n this.showingNode = undefined;\n } else {\n charIdx += 1;\n label.string = charArr.slice(0, charIdx).join('');\n }\n }, 50);\n }\n\n _makeRichTextTyper(richText: cc.RichText, str: string, finishCallFunc?: Function, showIngCallFunc?: Function, playSpeed: number = 1) {\n let delimiterCharList: any = ['✁', '✂', '✃', '✄', '✺', '✻', '✼', '❄', '❅', '❆', '❇', '❈', '❉', '❊'];\n let regexp = /<.+?\\/?>/g;\n let matchArr = str.match(regexp);\n let delimiterChar = delimiterCharList.find((item) => str.indexOf(item) == -1);\n let replaceStr = str.replace(regexp, delimiterChar);\n let tagInfoArr: any[] = [];\n let temp: number[] = [];\n let tagInfo: { endStr?; endtIdx?; startIdx?; startStr?} = {};\n let num = 0;\n for (let i = 0; i < replaceStr.length; i++) {\n if (replaceStr[i] == delimiterChar) {\n temp.push(i);\n if (temp.length >= 2) {\n if (matchArr)\n tagInfo.endStr = matchArr[tagInfoArr.length * 2 + 1];\n tagInfo.endtIdx = i - num;\n tagInfoArr.push(tagInfo);\n temp = [];\n tagInfo = {};\n } else {\n tagInfo.startIdx = i - num;\n if (matchArr)\n tagInfo.startStr = matchArr[tagInfoArr.length * 2];\n }\n num += 1;\n }\n }\n\n let showCharArr = str.replace(regexp, '').split('');\n let typerArr: string[] = [];\n for (let i = 1; i <= showCharArr.length; i++) {\n let temp = showCharArr.join('').slice(0, i);\n let addLen = 0;\n for (let j = 0; j < tagInfoArr.length; j++) {\n let tagInfo = tagInfoArr[j];\n let start = tagInfo.startIdx;\n let end = tagInfo.endtIdx;\n if (i > start && i <= end) {\n temp = temp.slice(0, start + addLen) + tagInfo.startStr + temp.slice(start + addLen) + tagInfo.endStr;\n addLen += tagInfo.startStr.length + tagInfo.endStr.length;\n } else if (i > end) {\n temp =\n temp.slice(0, start + addLen) +\n tagInfo.startStr +\n temp.slice(start + addLen, end + addLen) +\n tagInfo.endStr +\n temp.slice(end + addLen);\n addLen += tagInfo.startStr.length + tagInfo.endStr.length;\n }\n }\n typerArr.unshift(temp);\n }\n\n this.clearTimer()\n this.typerTimer = setInterval(() => {\n if (typerArr.length) {\n // this.isShowTyper = true;\n if (richText) {\n let str = typerArr.pop();\n richText.string = str ? str : \"\";\n if (showIngCallFunc) showIngCallFunc();\n }\n } else {\n this.showingString = \"\";\n this.showingNode = undefined;\n this.clearTimer();\n if (finishCallFunc) finishCallFunc();\n }\n }, 50 / playSpeed);\n }\n}"]}