import { _decorator, Component, Label } from 'cc'; import { EGlobalEvent } from '../MesEvent/EGlobalEvent'; import Language from '../Language'; import { Global } from '../Global'; import MesMgr from '../MesEvent/MesMgr'; const { ccclass, property ,menu} = _decorator; @ccclass('LabelCon') @menu("文本代理/文本控制") export class LabelCon extends Component { @property(Label) lab_Node:Label; isPlayAudio:boolean =false; isAutoHideActive:Boolean = false; time:number = 0.04; curTime:number = 0; tIndex:number= 0; mtips:string ="" showSaytips(tips: string, CallBack?: Function, daeltime: number = 0) { this.unscheduleAllCallbacks(); let audioName = Language.getValueSound(tips); if (audioName) { //MesMgr.event(EGlobalEvent.停止所有音效); //AudioUtils.instance.playEffect2(audioName, AppLanguage.audioBundle) } this.mtips = Language.getValue(tips); this.node.active = true; this.tIndex = 0; this.schedule(() => { if (this.tIndex > this.mtips.length) { this.unscheduleAllCallbacks(); if (daeltime > 0) { this.scheduleOnce(() => { this.isAutoHideActive && (this.node.active = false); CallBack && CallBack(); }, daeltime) } else { this.isAutoHideActive && (this.node.active = false); CallBack && CallBack(); } return; } this.lab_Node.string = this.mtips.slice(0, this.tIndex); this.tIndex++; }, this.time) } }