Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
elephant
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
elephant
Commits
307de46b
Commit
307de46b
authored
Feb 02, 2024
by
liujiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: use bundle load new skin
parent
7675b3ef
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
160 additions
and
42 deletions
+160
-42
elephant.fire
assets/elephant/scene/elephant.fire
+1
-1
dress.ts
assets/elephant/scene/model/dress.ts
+16
-14
pengpeng.ts
assets/elephant/scene/pengpeng.ts
+97
-11
pg.ts
assets/elephant/scene/pg.ts
+44
-14
builder.json
settings/builder.json
+1
-1
project.json
settings/project.json
+1
-1
No files found.
assets/elephant/scene/elephant.fire
View file @
307de46b
...
...
@@ -7751,7 +7751,7 @@
"defaultCover": {
"__uuid__": "97b97a55-719c-48ff-81e0-269363ee147c"
},
"_id": "
bbaF/xfq1D4ZUceYJYzAlJ
"
"_id": "
d7CwOQnuREtZv5XUoGzig/
"
},
{
"__type__": "cc.Node",
...
...
assets/elephant/scene/model/dress.ts
View file @
307de46b
...
...
@@ -8,20 +8,22 @@ class Dress {
cover
:
"
ani/cover.png
"
,
type
:
3
,
meta_value
:
{
"
eat
"
:
{
"
tex_png
"
:
"
ani/eating/eating_tex.png
"
,
"
ske_json
"
:
"
ani/eating/eating_ske.json
"
,
"
tex_json
"
:
"
ani/eating/eating_tex.json
"
,
"
armature
"
:
""
,
// "play": "default"
},
"
walk
"
:
{
"
tex_png
"
:
"
ani/walkinghungryhappy/walkinghungryhappy_tex.png
"
,
"
ske_json
"
:
"
ani/walkinghungryhappy/walkinghungryhappy_ske.json
"
,
"
tex_json
"
:
"
ani/walkinghungryhappy/walkinghungryhappy_tex.json
"
,
"
armature
"
:
"
Armature
"
,
"
animation
"
:
"
happy
"
,
// "play": ""
nodes
:
{
"
eat
"
:
{
"
tex_png
"
:
"
ani/eating/eating_tex.png
"
,
"
ske_json
"
:
"
ani/eating/eating_ske.json
"
,
"
tex_json
"
:
"
ani/eating/eating_tex.json
"
,
"
armature
"
:
""
,
// "play": "default"
},
"
walk
"
:
{
"
tex_png
"
:
"
ani/walkinghungryhappy/walkinghungryhappy_tex.png
"
,
"
ske_json
"
:
"
ani/walkinghungryhappy/walkinghungryhappy_ske.json
"
,
"
tex_json
"
:
"
ani/walkinghungryhappy/walkinghungryhappy_tex.json
"
,
"
armature
"
:
"
Armature
"
,
"
animation
"
:
"
happy
"
,
// "play": ""
}
}
},
};
...
...
assets/elephant/scene/pengpeng.ts
View file @
307de46b
...
...
@@ -40,20 +40,25 @@ export default class PengPeng extends cc.Component {
const
eatAsset
=
eatDragonDisplay
.
dragonAsset
;
const
eatArmatureName
=
eatDragonDisplay
.
armatureName
;
walkAtlasAsset
.
addRef
();
walkAsset
.
addRef
();
eatAtlasAsset
.
addRef
();
eatAsset
.
addRef
();
console
.
log
(
'
this.defaultCover.getTexture()
'
,
this
.
defaultCover
.
getTexture
())
dress
.
defaultSkin
.
cover
=
this
.
defaultCover
.
getTexture
();
dress
.
defaultSkin
.
meta_value
.
walk
.
tex_png
=
null
;
dress
.
defaultSkin
.
meta_value
.
walk
.
ske_json
=
walkAsset
dress
.
defaultSkin
.
meta_value
.
walk
.
tex_json
=
walkAtlasAsset
dress
.
defaultSkin
.
meta_value
.
eat
.
armature
=
walkArmatureName
dress
.
defaultSkin
.
meta_value
.
nodes
.
walk
.
tex_png
=
null
;
dress
.
defaultSkin
.
meta_value
.
nodes
.
walk
.
ske_json
=
walkAsset
dress
.
defaultSkin
.
meta_value
.
nodes
.
walk
.
tex_json
=
walkAtlasAsset
dress
.
defaultSkin
.
meta_value
.
nodes
.
walk
.
armature
=
walkArmatureName
dress
.
defaultSkin
.
meta_value
.
eat
.
tex_png
=
null
;
dress
.
defaultSkin
.
meta_value
.
eat
.
ske_json
=
eatAsset
dress
.
defaultSkin
.
meta_value
.
eat
.
tex_json
=
eatAtlasAsset
dress
.
defaultSkin
.
meta_value
.
eat
.
armature
=
eatArmatureName
dress
.
defaultSkin
.
meta_value
.
nodes
.
eat
.
tex_png
=
null
;
dress
.
defaultSkin
.
meta_value
.
nodes
.
eat
.
ske_json
=
eatAsset
dress
.
defaultSkin
.
meta_value
.
nodes
.
eat
.
tex_json
=
eatAtlasAsset
dress
.
defaultSkin
.
meta_value
.
nodes
.
eat
.
armature
=
eatArmatureName
}
dataReady
=
()
=>
{
console
.
log
(
'
pengpeng dataReady
'
);
...
...
@@ -199,9 +204,90 @@ export default class PengPeng extends cc.Component {
});
})
}
changeDress
(
data
)
{
console
.
log
(
'
changeDress1
'
,
dress
)
console
.
log
(
'
changeDress2
'
,
data
)
const
promiseArray
=
[];
const
bundleUrl
=
data
.
meta_value
.
bundle
;
const
version
=
data
.
meta_value
.
version
;
let
bundleOption
=
null
if
(
version
)
{
bundleOption
=
{
version
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
let
fn
=
cc
.
assetManager
.
loadBundle
.
bind
(
cc
.
assetManager
)
if
(
!
bundleUrl
)
{
fn
=
(
bundleUrl
,
option
,
cb
)
=>
{
if
(
!
bundleUrl
)
{
cb
(
null
,
null
)
}
}
}
fn
(
bundleUrl
,
bundleOption
,
(
err
,
bundle
)
=>
{
const
nodeNames
=
Object
.
keys
(
data
.
meta_value
.
nodes
);
for
(
let
i
=
0
;
i
<
nodeNames
.
length
;
i
++
)
{
const
nodeName
=
nodeNames
[
i
];
const
node
=
cc
.
find
(
nodeName
,
this
.
node
)
node
.
stopAllActions
();
if
(
node
)
{
const
meta
=
data
.
meta_value
.
nodes
[
nodeName
];
const
dragonDisplay
=
node
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
// const imageUrl = meta['tex_png'];
const
skeUrl
=
meta
[
'
ske_json
'
];
const
atlasUrl
=
meta
[
'
tex_json
'
];
const
armatureName
=
meta
[
'
armature
'
];
const
animationName
=
meta
[
'
animation
'
];
const
properties
=
meta
[
'
node
'
];
const
offset
=
meta
[
'
offset
'
];
console
.
log
(
nodeName
,
armatureName
,
node
)
dragonDisplay
.
dragonAsset
=
null
;
dragonDisplay
.
dragonAtlasAsset
=
null
;
dragonDisplay
.
armatureName
=
""
;
const
proc
=
new
Promise
((
resolve1
,
reject1
)
=>
{
pg
.
load
.
loadFromBundle
(
bundle
,
[
[
atlasUrl
,
dragonBones
.
DragonBonesAtlasAsset
],
[
skeUrl
,
dragonBones
.
DragonBonesAsset
]
]).
then
(([
atlas
,
asset
])
=>
{
dragonDisplay
.
dragonAtlasAsset
=
atlas
;
console
.
log
(
8
)
dragonDisplay
.
dragonAsset
=
asset
;
console
.
log
(
9
)
dragonDisplay
.
armatureName
=
armatureName
;
console
.
log
(
10
)
const
armature
=
dragonDisplay
.
armature
()
// armature.animation.animationNames
console
.
log
(
'
animationName
'
,
node
.
name
,
armatureName
,
animationName
,
armature
?
armature
.
animation
.
animationNames
:
[])
if
(
animationName
)
{
dragonDisplay
.
playAnimation
(
animationName
,
0
);
}
node
.
scaleX
=
1
;
node
.
scaleY
=
1
;
if
(
properties
)
{
Object
.
keys
(
properties
).
forEach
(
key
=>
{
node
[
key
]
=
properties
[
key
];
})
}
if
(
offset
)
{
Object
.
keys
(
offset
).
forEach
(
key
=>
{
node
[
key
]
+=
+
offset
[
key
];
})
}
resolve1
()
})
})
promiseArray
.
push
(
proc
)
}
}
})
Promise
.
all
(
promiseArray
).
then
(()
=>
{
resolve
()
})
})
}
changeDress____123123
(
data
)
{
console
.
log
(
'
changeDress1
'
,
dress
)
console
.
log
(
'
changeDress2
'
,
data
)
const
promiseArray
=
[];
...
...
@@ -226,7 +312,7 @@ export default class PengPeng extends cc.Component {
console
.
log
(
nodeName
,
armatureName
,
node
)
pg
.
load
.
loadAssets
([
[
imageUrl
],
[
imageUrl
,{
ext
:
'
.png
'
,
type
:
cc
.
Texture2D
}
],
[
atlasUrl
,
{
ext
:
'
.txt
'
,
type
:
dragonBones
.
DragonBonesAtlasAsset
}],
[
skeUrl
,
{
ext
:
'
.txt
'
,
type
:
dragonBones
.
DragonBonesAsset
}]
]).
then
((
assets
:
any
[])
=>
{
...
...
assets/elephant/scene/pg.ts
View file @
307de46b
...
...
@@ -278,24 +278,54 @@ let pg = {
},
load
:
{
//资源加载
// loadBundle: function (bundleName) {
// return new Promise((resolve, reject) => {
// // let hallBundle = cc.assetManager.getBundle(`hall`);
// // hallBundle.releaseAll();
// // cc.assetManager.removeBundle(hallBundle);
// let bundle = cc.assetManager.getBundle(bundleName);
// if (bundle) return resolve('');
// cc.assetManager.loadBundle(bundleName, (err, bundle) => {
// if (err) return cc.error(err);
// resolve(bundle);
// });
// });
// },
loadBundle
:
function
(
bundleUri
,
options
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
bundleUri
)
{
resolve
();
return
}
// let hallBundle = cc.assetManager.getBundle(`hall`);
// hallBundle.releaseAll();
// cc.assetManager.removeBundle(hallBundle);
let
bundle
=
cc
.
assetManager
.
getBundle
(
bundleUri
);
if
(
bundle
)
return
resolve
(
''
);
cc
.
assetManager
.
loadBundle
(
bundleUri
,
options
,
(
err
,
bundle
)
=>
{
if
(
err
)
{
reject
(
err
)
return
cc
.
error
(
err
)
};
resolve
(
bundle
);
});
});
},
loadFromBundle
:
function
(
bundle
,
params
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
tasks
=
params
.
map
(
p
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
typeof
p
[
0
]
==
'
string
'
)
{
bundle
.
load
(
p
[
0
],
p
[
1
],
(
err
,
data
)
=>
{
if
(
err
&&
!
data
)
return
reject
(
err
);
resolve
(
data
);
});
}
else
{
resolve
(
p
[
0
]);
}
})
});
Promise
.
all
(
tasks
).
then
((
res
)
=>
{
resolve
(
res
);
}).
catch
(
e
=>
{
reject
(
e
);
})
})
},
loadRes
:
function
(
res
,
type
,
bundleName
)
{
//此处需要二次封装,新的存在assetbundle
return
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
loader
.
loadRes
(
res
,
type
,
(
err
,
data
)
=>
{
if
(
err
&&
!
data
)
return
reject
(
pg
.
logger
.
d
(
'
loading loadRes error->
'
+
res
)
);
if
(
err
&&
!
data
)
return
reject
(
err
);
resolve
(
data
);
});
})
...
...
settings/builder.json
View file @
307de46b
...
...
@@ -16,7 +16,7 @@
"mainCompressionType"
:
"default"
,
"mainIsRemote"
:
false
,
"optimizeHotUpdate"
:
false
,
"md5Cache"
:
fals
e
,
"md5Cache"
:
tru
e
,
"nativeMd5Cache"
:
true
,
"encryptJs"
:
true
,
"xxteaKey"
:
"af95a0f7-a8da-4f"
,
...
...
settings/project.json
View file @
307de46b
{
"last-module-event-record-time"
:
1
655180857809
,
"last-module-event-record-time"
:
1
706792034745
,
"migrate-history"
:
[
"cloud-function"
],
...
...
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