12345678910111213141516171819202122232425 |
- 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!;
- start() {
- this.gunAnimation = this.node.getComponent(Animation)!;
- EventDispatcher.instance.on(GameEvent.EVENT_PLAY_GUN_ANIMATION,this.playGunAnimation,this);
- }
- playGunAnimation(){
- if(!this.gunAnimation){
- return;
- }
- this.gunAnimation.play();
- }
- }
|