import { UITransform } from "cc";
import { Node } from "cc";
import { sp } from "cc";
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
import { GData } from "../../../consts/GData";
import GNode from "./GNode";

export default class GEffectUtil {
    
    //创建一个Spine特效
    static create(spine:sp.SkeletonData):JNSkeleton{
        let effectNode = GNode.create();
        effectNode.addComponent(UITransform);
        let ske = effectNode.addComponent(JNSkeleton);
        ske.skeletonData = spine;
        ske.premultipliedAlpha = false;
        return ske;
    }

    //创建只播放一次的Spine特效
    static createOne(spine:sp.SkeletonData):JNSkeleton{
        let ske = GEffectUtil.create(spine);
        ske.setCompleteListener(() => {
            ske.node.destroy();
        })
        return ske;
    }

}


