import { _decorator, Animation, AnimationClip, AnimationState, Component, Node } from 'cc'; import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher'; import { GameEvent } from '../Enum/GameEvent'; const { ccclass, property } = _decorator; @ccclass('GunComponent') export class GunComponent extends Component { gunAnimation: Animation = null!; protected onLoad(): void { this.gunAnimation = this.node.getComponent(Animation)!; } start() { EventDispatcher.instance.on(GameEvent.EVENT_PLAY_GUN_ANIMATION,this.playGunAnimation,this); } playGunAnimation(){ this.gunAnimation.play(); } }