123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import { SpriteFrame,Sprite,resources,_decorator } from "cc";
- const { ccclass, property } = _decorator;
- @ccclass('ResMng')
- export class ResMng {
- private static _instance: ResMng | null = null;
-
- private constructor() { }
- public static get Instance() {
- if (ResMng._instance === null)
- ResMng._instance = new ResMng();
- return ResMng._instance;
- }
-
- static LoadImg(spNameUrl: string, img: Sprite,callback:Function=null,obj:any=null) {
- resources.load("img/" + spNameUrl+'/spriteFrame', SpriteFrame, (e, sp: SpriteFrame) => {
- if(e){
- console.log("not find","img/" + spNameUrl)
- }else{
- if (img && sp)
- img.spriteFrame = sp;
- if(callback)callback.call(obj);
- }
- })
-
- }
- static LoadAvatar(spNameUrl: string, img: Sprite,callback:Function=null,obj:any=null) {
- resources.load("avatar/" + spNameUrl+'/spriteFrame', SpriteFrame, (e, sp: SpriteFrame) => {
- if(e){
- console.log("not find","avatar/" + spNameUrl)
- }else{
- if (img && sp)
- img.spriteFrame = sp;
- if(callback)callback.call(obj);
- }
- })
-
- }
- static LoadEmote(spNameUrl: string, img: Sprite,callback:Function=null,obj:any=null) {
- resources.load("chat_emote/" + spNameUrl+'/spriteFrame', SpriteFrame, (e, sp: SpriteFrame) => {
- if(e){
- console.log("not find","avatar/" + spNameUrl)
- }else{
- if (img && sp)
- img.spriteFrame = sp;
- if(callback)callback.call(obj);
- }
- })
-
- }
- static LoadItem(spNameUrl: string, img: Sprite,callback:Function=null,obj:any=null) {
- resources.load("item/" + spNameUrl+'/spriteFrame', SpriteFrame, (e, sp: SpriteFrame) => {
- if(e){
- console.log("not find","img/" + spNameUrl)
- }else{
- if (img && sp)
- img.spriteFrame = sp;
- if(callback)callback.call(obj);
- }
- })
-
- }
- }
|