Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_njstar
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
middleLayer_for_njstar
Commits
0843d964
Commit
0843d964
authored
3 years ago
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: asyncLoadDragonBoneAnime
parent
3b680f1f
master
v23
v22
v21
v19
v18
v17
v16
v15
v14
v13
v12
v11
v10
v9
v8
v7
v6
v5
v4
v3
v2
v1
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
.DS_Store
.DS_Store
+0
-0
util.ts
assets/cocos_generator/script/util.ts
+67
-0
No files found.
.DS_Store
View file @
0843d964
No preview for this file type
This diff is collapsed.
Click to expand it.
assets/cocos_generator/script/util.ts
View file @
0843d964
...
...
@@ -189,6 +189,73 @@ export async function asyncDelay(time) {
})
}
export
async
function
asyncLoadDragonBoneAnime
(
node
,
{
skeJsonData
:
{
url
:
skeJsonDataUrl
},
texJsonData
:
{
url
:
texJsonDataUrl
},
texPngData
:
{
url
:
texPngDataUrl
}
})
{
if
(
!
texPngDataUrl
||
!
texJsonDataUrl
||
!
texPngDataUrl
||
texPngDataUrl
==
''
||
texJsonDataUrl
==
''
||
texPngDataUrl
==
''
)
{
return
;
}
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
node
.
animaNode
)
{
node
.
animaNode
.
removeFromParent
();
}
const
animaNode
=
new
cc
.
Node
();
animaNode
.
name
=
'
animaNode
'
;
animaNode
.
parent
=
node
;
animaNode
.
active
=
true
;
node
.
animaNode
=
animaNode
;
const
dragonDisplay
=
animaNode
.
addComponent
(
dragonBones
.
ArmatureDisplay
);
const
loadTexture
=
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
assetManager
.
loadRemote
(
texPngDataUrl
,
(
error
,
texture
)
=>
{
if
(
error
)
{
reject
(
error
);
}
resolve
(
texture
);
});
});
const
loadTexJsonData
=
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
assetManager
.
loadAny
({
url
:
texJsonDataUrl
},
(
error
,
atlasJson
)
=>
{
if
(
error
)
{
reject
(
error
);
}
resolve
(
atlasJson
);
});
});
const
loadSkeJsonData
=
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
assetManager
.
loadAny
({
url
:
skeJsonDataUrl
},
(
error
,
dragonBonesJson
)
=>
{
if
(
error
)
{
reject
(
error
);
}
resolve
(
dragonBonesJson
);
});
});
Promise
.
all
([
loadTexture
,
loadTexJsonData
,
loadSkeJsonData
]).
then
(([
texture
,
atlasJson
,
dragonBonesJson
])
=>
{
const
atlas
=
new
dragonBones
.
DragonBonesAtlasAsset
();
atlas
.
atlasJson
=
JSON
.
stringify
(
atlasJson
);
atlas
.
texture
=
texture
;
const
asset
=
new
dragonBones
.
DragonBonesAsset
();
asset
.
dragonBonesJson
=
JSON
.
stringify
(
dragonBonesJson
);
dragonDisplay
.
dragonAtlasAsset
=
atlas
;
dragonDisplay
.
dragonAsset
=
asset
;
let
armatureNames
=
dragonBonesJson
.
armature
.
map
(
data
=>
data
.
name
);
if
(
armatureNames
.
length
>
0
)
{
dragonDisplay
.
armatureName
=
armatureNames
[
0
];
}
resolve
(
animaNode
);
});
});
}
export
class
FireworkSettings
{
baseNode
;
// 父节点
nodeList
;
// 火花节点的array
...
...
This diff is collapsed.
Click to expand it.
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