Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-engine
Commits
0d95aa07
Commit
0d95aa07
authored
May 12, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复素材预加载分组
parent
93c3357a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
32 deletions
+52
-32
GameStage.ts
src/zeroing/game-warpper/GameStage.ts
+52
-32
No files found.
src/zeroing/game-warpper/GameStage.ts
View file @
0d95aa07
...
...
@@ -111,18 +111,24 @@ export class GameStage extends Node {
*/
async
launch
(
config
,
onPreloadAssetsProgress
?,
onPreloadAssetsComplete
?,
onStart
?)
{
this
.
_config
=
config
;
const
{
assets
,
customs
}
=
config
;
let
loaded
=
0
;
let
assetsToLoad
=
assets
;
if
(
!
Array
.
isArray
(
assets
))
{
//如果是分组后的配置就加载共用分组,否则加载全部
assetsToLoad
=
assets
[
'common'
];
const
{
options
:
{
env
},
dataMapping
,
processes
,
builtinProcesses
,
customs
}
=
this
.
_config
;
Stage
.
addUpdateObj
(
Tween
);
injectEnv
(
env
);
//registerScripts(scripts);
//registerCustomModuleFromConfig(customs);
registerCustomModules
(
customs
);
if
(
dataMapping
)
{
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
}
let
total
=
assetsToLoad
.
length
;
setProcessMetaLibs
(
processes
,
builtinProcesses
)
;
await
loadAssets
(
assetsToLoad
,
p
).
catch
(
e
=>
{
console
.
log
(
e
);
});
await
this
.
loadPreloadAssets
(
onPreloadAssetsProgress
,
onPreloadAssetsComplete
);
this
.
start
();
...
...
@@ -133,36 +139,14 @@ export class GameStage extends Node {
setTimeout
(
this
.
lazyLoadAllAssets
,
this
.
_config
.
options
.
lazyLoadWait
||
1000
);
function
p
()
{
loaded
++
;
onPreloadAssetsProgress
&&
onPreloadAssetsProgress
(
loaded
,
total
);
if
(
loaded
>=
total
)
{
onPreloadAssetsComplete
&&
onPreloadAssetsComplete
();
}
}
}
/**
* 开始游戏
*/
start
()
{
const
{
options
:
{
entrySceneView
,
env
},
dataMapping
,
processes
,
builtinProcesses
,
scripts
,
customs
}
=
this
.
_config
;
const
{
options
:
{
entrySceneView
,
},
}
=
this
.
_config
;
Stage
.
addUpdateObj
(
Tween
);
injectEnv
(
env
);
//registerScripts(scripts);
//registerCustomModuleFromConfig(customs);
registerCustomModules
(
customs
);
if
(
dataMapping
)
{
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
}
setProcessMetaLibs
(
processes
,
builtinProcesses
);
setTimeout
(
async
()
=>
{
let
sceneEntry
=
await
this
.
instantiateView
(
entrySceneView
);
...
...
@@ -331,5 +315,41 @@ export class GameStage extends Node {
await
loadAssetsGroup
(
group
,
custom
.
id
);
}
}
};
async
loadPreloadAssets
(
onPreloadAssetsProgress
,
onPreloadAssetsComplete
){
const
{
assets
,
}
=
this
.
_config
;
let
loaded
=
0
;
let
assetsToLoad
=
assets
;
let
total
;
if
(
!
Array
.
isArray
(
assets
))
{
//如果是分组后的配置就加载共用分组,否则加载全部
assetsToLoad
=
assets
[
'common'
];
if
(
assetsToLoad
.
length
>
0
){
await
this
.
showInnerLoadingView
();
await
loadAssetsGroups
({
preload
:
assetsToLoad
,
},
async
()
=>
{
},
async
()
=>
{
this
.
hideInnerLoadingView
();
});
}
}
else
{
total
=
assetsToLoad
.
length
;
await
loadAssets
(
assetsToLoad
,
p
).
catch
(
e
=>
{
console
.
log
(
e
);
});
}
function
p
()
{
loaded
++
;
onPreloadAssetsProgress
&&
onPreloadAssetsProgress
(
loaded
,
total
);
if
(
loaded
>=
total
)
{
onPreloadAssetsComplete
&&
onPreloadAssetsComplete
();
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment