class HYLoader {
	getSprNode(resName) {
		const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
		const node = new cc.Node();
		node.addComponent(cc.Sprite).spriteFrame = sf;
		return node;
	}
    getSpriteFrimeByUrl(url, cb) {
        cc.loader.load({ url }, (err, img) => {
            const spriteFrame = new cc.SpriteFrame(img)
            if (cb) {
                cb(spriteFrame);
            }
        })
    }
    getSprNodeByUrl(url, cb) {
        const node = new cc.Node();
        const spr = node.addComponent(cc.Sprite);
        this.getSpriteFrimeByUrl(url, (sf) => {
            spr.spriteFrame = sf;
            if (cb) {
                cb(node);
            }
        })
    }
    playAudioByUrl(audio_url, cb = null) {
        if (audio_url) {
            cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
                const audioId = cc.audioEngine.play(audioClip, false, 0.8);
                if (cb) {
                    cc.audioEngine.setFinishCallback(audioId, () => {
                        cb();
                    });
                }
            });
        }
    }
}
export const hyLoader = new HYLoader();