import { _decorator, Component, Node, tween, Vec3, AudioSource } from 'cc'; import { GameEvent } from '../Common/Base/GameEventConfig'; import GameEventManager from '../Common/Base/GameEventManager'; import { Global } from '../Common/Global'; const { ccclass, property } = _decorator; @ccclass('GameAnimal') export class GameAnimal extends Component { audioPlaying:boolean=false; pause:boolean=false; audioTime=0; timerCount=0; start() { // this.node.on(Node.EventType.TOUCH_END, this._onTouchEndNode, this); // this.node.on(Node.EventType.TOUCH_CANCEL, this._onTouchEndNode, this); this.setDefault(); this.node.setScale(Vec3.ZERO); } update(deltaTime: number) { } // _onTouchEndNode(){ // GameEventManager.getInstance().dispathcGameEvent(GameEvent.ClickUp,this.node.name); // } BiggerAnimal(flag:boolean){ if(flag){ this.node.setScale(new Vec3(1.2,1.2,1)); }else{ this.node.setScale(new Vec3(1,1,1)); } } beforeDestroy(){ // this.node.off(Node.EventType.TOUCH_END, this._onTouchEndNode, this); // this.node.off(Node.EventType.TOUCH_CANCEL, this._onTouchEndNode, this); } setIsRight(isright){ this.node.children[1].active=isright; this.node.children[2].active=!isright; } setDefault(){ this.node.children[1].active=false; this.node.children[2].active=false; this.BiggerAnimal(false); } onDestroy(){ } pausePlay(){ if(this.audioPlaying){ this.node.getComponent(AudioSource).pause(); this.pause=true; } } RestartPlay(){ if(this.audioPlaying){ this.node.getComponent(AudioSource).play(); this.pause=false; } } PlayMyAudio(func){ let audio=this.node.getComponent(AudioSource); audio.play(); this.audioPlaying=true; this.audioTime=audio.duration; Global.cdSchedule.schedule(()=>{ if(func){ func(); } Global.cdSchedule.unschedule(this.node.name); },this.audioTime,this.node.name) } ShowCard(func){ tween(this.node).to(0.4,{scale:new Vec3(1,1,1)},{ easing: 'elasticOut' }).call(()=>{ if(func){ func(); } }).start(); } }