
import { props } from '../props';
import {getTextureByName} from "./utils";

export class SvgaManager {

    public static createSvga(name) {
        let inst = new svga.Svga();
        inst.source = engine.getAssetByName(name).uuid;
        // let anchor = props[(anchorName)];
        // if (anchor) {
        // 	inst.x = -anchor.x;
        // 	inst.y = -anchor.y;
    
        // 	inst.anchorX = anchor.x;
        // 	inst.anchorY = anchor.y;
        // }
        return inst;
    }
    
    public static play(svga,callBack?){
        if(!svga){console.log('svga节点出错');return;}
        svga.gotoAndStop(0);
        svga.play();
        if(callBack){
            svga.addEventListener(engine.Event.END_FRAME,()=>{
                svga.stop();
                callBack();
                svga.removeAllEventListener();
            },this) 
        }
    }

    public static stop(svga){
        if(!svga){console.log('svga节点出错');return;}
        svga.stop();
    }
}