Spring774
2025-11-12 2379cc78112ecbe65a9fcb817d6441875f785803
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import EffectManager, { EffectType } from "./EffectManager";
 
const {ccclass, property} = cc._decorator;
 
@ccclass
export default class SpineEffect extends cc.Component {
    
    @property
    effectType: EffectType = 0;
 
    private spine: sp.Skeleton = null;
    private manager: EffectManager;
    onLoad(){
        this.spine = this.getComponent(sp.Skeleton);
        this.spine.setCompleteListener(function(){
            this.playEnd();
        }.bind(this));
    }
 
    play(name: string){
        let t = this.spine.setAnimation(0, name, false);
    }
 
    private playEnd(){
        this.spine.setToSetupPose();
        this.recycle();
    }
 
    recycle(){
        if (this.manager){
            this.manager.recycleEffect(this);
        }
    }
 
    reuse(manager: EffectManager){
        this.manager = manager;
    }
}