mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-13 02:26:07 +00:00
提交
This commit is contained in:
@@ -30,10 +30,10 @@ import { Component } from "cc";
|
||||
|
||||
// let APIPath = `http://localhost:8080`
|
||||
// let WsPath = `ws://localhost:8080/websocket`
|
||||
let APIPath = `http://192.168.1.23:8080`
|
||||
let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||
// let APIPath = `http://192.168.0.113:8080`
|
||||
// let WsPath = `ws://192.168.0.113:8080/websocket`
|
||||
// let APIPath = `http://192.168.1.23:8080`
|
||||
// let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||
let APIPath = `http://192.168.0.128:8080`
|
||||
let WsPath = `ws://192.168.0.128:8080/websocket`
|
||||
// let APIPath = `https://api.pet.jisol.cn`
|
||||
// let WsPath = `wss://api.pet.jisol.cn/websocket`
|
||||
|
||||
@@ -148,7 +148,7 @@ export class JLoaderBattle extends JLoaderSystem{
|
||||
|
||||
//资源
|
||||
resources:{[id:number]:Asset} = {};
|
||||
foreverResources:number[] = []; //永久资源Id
|
||||
battleResources:number[] = []; //战斗资源Id
|
||||
|
||||
async onInit(): Promise<any> {
|
||||
|
||||
@@ -161,28 +161,28 @@ export class JLoaderBattle extends JLoaderSystem{
|
||||
app.loading.setCurrent(JLoaderBattle.loadingInit);
|
||||
|
||||
//默认加载全部资源
|
||||
await this.loadForeverResources(...TD.TbBattleResource.getDataList());
|
||||
await this.loadBattleResources(...TD.TbBattleResource.getDataList());
|
||||
|
||||
app.loading.ok(JLoaderBattle.loadingInit);
|
||||
|
||||
}
|
||||
|
||||
//加载永久资源
|
||||
async loadForeverResources(...ress:TB.TbBattleResource[]){
|
||||
//加载战斗资源
|
||||
async loadBattleResources(...ress:TB.TbBattleResource[]){
|
||||
|
||||
for (const res of ress) {
|
||||
await this.loadForeverResource(res);
|
||||
await this.loadBattleResource(res);
|
||||
}
|
||||
|
||||
}
|
||||
//加载永久资源
|
||||
loadForeverResource(res:TB.TbBattleResource){
|
||||
//加载战斗资源
|
||||
loadBattleResource(res:TB.TbBattleResource){
|
||||
return (new Promise<void>(r => {
|
||||
|
||||
let Type:new ()=>Asset = [sp.SkeletonData,SpriteFrame][res.type];
|
||||
|
||||
this.bundle.load(res.path,Type,(error,data) => {
|
||||
if(this.foreverResources.indexOf(res.id) < 0){
|
||||
if(this.battleResources.indexOf(res.id) < 0){
|
||||
//添加永久资源
|
||||
this.resources[res.id] = data;
|
||||
data.addRef();
|
||||
@@ -213,14 +213,14 @@ export class JLoaderBattle extends JLoaderSystem{
|
||||
}))
|
||||
}
|
||||
|
||||
//销毁永久资源
|
||||
clearForeverResources(...ress:TB.TbBattleResource[]){
|
||||
this.foreverResources.forEach(id => {
|
||||
//销毁长久资源
|
||||
clearBattleResources(...ress:TB.TbBattleResource[]){
|
||||
this.battleResources.forEach(id => {
|
||||
if(this.resources[id]){
|
||||
this.resources[id].decRef();
|
||||
}
|
||||
});
|
||||
this.foreverResources = [];
|
||||
this.battleResources = [];
|
||||
this.onUpdateResources();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user