12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { isValid, Sprite, SpriteAtlas, SpriteFrame } from "cc"
- import { AssetType, resLoader } from "../res/ResLoader"
- import { AsyncQueue, NextFunction } from "../queue/AsyncQueue";
- export enum HeadSpriteType{
-
- Critical = 0,
-
- Square,
-
- Round,
- }
- export class MaterialUtil {
- static iconGame: SpriteAtlas = null;
- static iconFilter: SpriteAtlas = null;
-
- static iconHead: SpriteFrame = null;
- static Restart() {
- }
- static init(callback) {
- let queue = new AsyncQueue();
- queue.pushMulti("InitPool", async (next: NextFunction, params: any, args: any) => {
- resLoader.load('package', 'texture/head/end_0_1/spriteFrame', SpriteFrame, (error: Error, res: SpriteFrame) => {
- if (!error) {
- this.iconHead = res;
- if(callback) callback();
- next()
- console.log('头像图标加载完成');
- }
- });
-
-
-
-
-
-
-
-
-
- });
- queue.complete = () => {
- console.log('materialUtil初始化完成');
- };
-
- queue.play();
- }
- _loadRes(LoadType: AssetType, Url, Back) {
- resLoader.load('package', Url, LoadType, (error: Error, res) => {
- if (!error) {
- Back(res)
- }
- });
- }
-
-
-
-
-
-
-
-
-
- static getHeadByID(id,sprite:Sprite,headType:HeadSpriteType = HeadSpriteType.Critical) {
-
- resLoader.load('package', 'texture/head/end_0_'+id+"/spriteFrame", SpriteFrame, (error: Error, res: SpriteFrame) => {
- if (!error && isValid(sprite)) {
- sprite.spriteFrame = res;
- }
- })
-
- }
- }
|