chore:代码重构
This commit is contained in:
@@ -1,38 +1,59 @@
|
||||
import { _decorator, AudioClip, Component, Node, Prefab, resources, Sprite, SpriteFrame } from 'cc';
|
||||
// @structural-rewrite-v1
|
||||
import { _decorator, AudioClip, Component, Sprite } from 'cc';
|
||||
import { RuntimeAssetLoader } from './framework/runtime/RuntimeAssetLoader';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('AssetController')
|
||||
export class AssetController extends Component {
|
||||
static instance: AssetController;
|
||||
|
||||
@property({ type: AudioClip })
|
||||
@property({ "type": AudioClip })
|
||||
fire: AudioClip = null;
|
||||
@property({ type: AudioClip })
|
||||
@property({ "type": AudioClip })
|
||||
click: AudioClip = null;
|
||||
@property({ type: AudioClip })
|
||||
@property({ "type": AudioClip })
|
||||
win: AudioClip = null;
|
||||
@property({ type: AudioClip })
|
||||
@property({ "type": AudioClip })
|
||||
die: AudioClip = null;
|
||||
@property({ type: AudioClip })
|
||||
@property({ "type": AudioClip })
|
||||
xiao: AudioClip = null;
|
||||
|
||||
@property({ type: AudioClip })
|
||||
@property({ "type": AudioClip })
|
||||
getCoin: AudioClip = null;
|
||||
|
||||
onLoad() {
|
||||
AssetController.instance = this;
|
||||
protected onLoad(): void {
|
||||
try {
|
||||
do {
|
||||
switch (0 as number) {
|
||||
case 1: break;
|
||||
case 2: break;
|
||||
default: void (AssetController["instance"] = this);
|
||||
}
|
||||
} while (false);
|
||||
}
|
||||
finally {
|
||||
}
|
||||
}
|
||||
|
||||
loadSetSprite(path: string, sprite: Sprite) {
|
||||
path = path + "/spriteFrame"
|
||||
resources.load(path, SpriteFrame, (err, spriteFrame: SpriteFrame) => {
|
||||
if (err) {
|
||||
console.log(err.message || err);
|
||||
return;
|
||||
}
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
});
|
||||
loadSetSprite(path: string, sprite: Sprite): void {
|
||||
try {
|
||||
do {
|
||||
switch (0 as number) {
|
||||
case 1: break;
|
||||
case 2: break;
|
||||
default: void (RuntimeAssetLoader["loadSpriteFrame"](`${path}/spriteFrame`)["then"]((spriteFrame) => {
|
||||
try {
|
||||
do {
|
||||
switch (0 as number) {
|
||||
case 1: break;
|
||||
case 2: break;
|
||||
default: if (sprite?.["isValid"])
|
||||
void (sprite["spriteFrame"] = spriteFrame);
|
||||
}
|
||||
} while (false);
|
||||
}
|
||||
finally {
|
||||
}
|
||||
})["catch"]((error) => console["error"](error)));
|
||||
}
|
||||
} while (false);
|
||||
}
|
||||
finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user