完善 docs

This commit is contained in:
SmallMain
2022-06-17 18:42:43 +08:00
parent a815401a2c
commit 142e19d075
45 changed files with 11534 additions and 149 deletions

24
demo/assets/home.meta Normal file
View File

@@ -0,0 +1,24 @@
{
"ver": "1.1.2",
"uuid": "ec375606-0adb-4461-aa8a-c7e374bc920b",
"isBundle": true,
"bundleName": "",
"priority": 1,
"compressionType": {
"web-mobile": "merge_all_json",
"web-desktop": "merge_all_json"
},
"optimizeHotUpdate": {
"web-mobile": false,
"web-desktop": false
},
"inlineSpriteFrames": {
"web-mobile": false,
"web-desktop": false
},
"isRemoteBundle": {
"web-mobile": false,
"web-desktop": false
},
"subMetas": {}
}

View File

@@ -0,0 +1,257 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "home",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 600
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
480,
300,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "tips",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 128,
"g": 128,
"b": 128,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 522.005,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-259.63200000000006,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
null
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "源码https://github.com/smallmain/cocos-service-pack/tree/master/demo",
"_N$string": "源码https://github.com/smallmain/cocos-service-pack/tree/master/demo",
"_fontSize": 16,
"_lineHeight": 20,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 2,
"_N$autoSwitchMaterial": 0,
"_N$allowDynamicAtlas": 0,
"_N$enableRetina": 0,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 17,
"_left": 95.11500000000001,
"_right": 0,
"_top": 549.6320000000001,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "e311a003-c0a1-4ff9-9983-2154de145eb7"
},
"fileId": "60yhtKNmhJBa7a+vJD0YMi",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "e311a003-c0a1-4ff9-9983-2154de145eb7"
},
"fileId": "",
"sync": false
}
]

View File

@@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "e311a003-c0a1-4ff9-9983-2154de145eb7",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@@ -12,53 +12,89 @@ export default class LeftArea extends cc.Component {
@property(cc.Node)
multiBatcher: cc.Node = null;
@property(cc.Node)
charMode: cc.Node = null;
@property(cc.Node)
highDPI: cc.Node = null;
@property(cc.Node)
spineBatch: cc.Node = null;
@property(cc.Node)
spineSkin: cc.Node = null;
@property(cc.Node)
mainArea: cc.Node = null;
start() {
this.home.on('toggle', (toggle: cc.Toggle) => {
if (toggle.isChecked) {
this.changePage(toggle.node);
}
});
this.multiMaterial.on('toggle', (toggle: cc.Toggle) => {
if (toggle.isChecked) {
this.changePage(toggle.node);
}
});
this.multiBatcher.on('toggle', (toggle: cc.Toggle) => {
if (toggle.isChecked) {
this.changePage(toggle.node);
}
});
}
tick = 0;
changePage(node: cc.Node) {
const cur = ++this.tick;
const map = new Map<cc.Node, { bundle: string, path: string }>([
map: Map<cc.Node, { bundle: string, path: string }>
[this.multiMaterial, { bundle: "multi-render", path: "multi-material/multi-material" }],
[this.multiBatcher, { bundle: "multi-render", path: "multi-batcher/multi-batcher" }],
start() {
this.map = new Map([
[this.home, {
bundle: "home",
path: "home",
}],
[this.multiMaterial, {
bundle: "multi-render",
path: "multi-material/multi-material",
}],
[this.multiBatcher, {
bundle: "multi-render",
path: "multi-batcher/multi-batcher",
}],
[this.charMode, {
bundle: "text-render",
path: "char-mode/char-mode",
}],
[this.highDPI, {
bundle: "text-render",
path: "high-dpi/high-dpi",
}],
[this.spineBatch, {
bundle: "spine",
path: "batch/spine-batch",
}],
[this.spineSkin, {
bundle: "spine",
path: "skin/spine-skin",
}],
]);
this.mainArea.destroyAllChildren();
this.initBtns();
}
const route = map.get(node);
if (route) {
cc.assetManager.loadBundle(route.bundle, (err, bundle) => {
if (!err) {
bundle.load(route.path, cc.Prefab, (err, prefab: cc.Prefab) => {
if (!err && cur === this.tick) {
this.mainArea.addChild(cc.instantiate(prefab));
}
});
initBtns() {
for (const [node, route] of this.map) {
node.on('toggle', (toggle: cc.Toggle) => {
if (toggle.isChecked) {
const cur = ++this.tick;
this.mainArea.destroyAllChildren();
if (route) {
cc.assetManager.loadBundle(route.bundle, (err, bundle) => {
if (!err) {
bundle.load(route.path, cc.Prefab, (err, prefab: cc.Prefab) => {
if (!err && cur === this.tick) {
this.mainArea.addChild(cc.instantiate(prefab));
}
});
}
});
}
}
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -338,7 +338,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 482.72,
"width": 445.375,
"height": 40
},
"_anchorPoint": {
@@ -388,8 +388,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "点击按钮会将这 8 张纹理关联同一个材质,能看到 drawcall 降低 7",
"_N$string": "点击按钮会将这 8 张纹理关联同一个材质,能看到 drawcall 降低 7",
"_string": "点击按钮会将这 8 张纹理关联同一个材质, Draw Call 降低 7",
"_N$string": "点击按钮会将这 8 张纹理关联同一个材质, Draw Call 降低 7",
"_fontSize": 16,
"_lineHeight": 40,
"_enableWrapText": true,

24
demo/assets/spine.meta Normal file
View File

@@ -0,0 +1,24 @@
{
"ver": "1.1.2",
"uuid": "b420e7e4-907e-46c1-b7dd-4796fb1edebe",
"isBundle": true,
"bundleName": "",
"priority": 1,
"compressionType": {
"web-desktop": "merge_all_json",
"web-mobile": "merge_all_json"
},
"optimizeHotUpdate": {
"web-desktop": false,
"web-mobile": false
},
"inlineSpriteFrames": {
"web-desktop": false,
"web-mobile": false
},
"isRemoteBundle": {
"web-desktop": false,
"web-mobile": false
},
"subMetas": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "21700e21-cd6e-4f4e-88f8-c97c886e2e5c",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "76663793-b023-4931-89fb-febc115c2a43",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "51588566-10c7-4926-847c-4b69bf536e7b",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "03129ae1-98e5-4264-a51b-6f95f23d742a",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@@ -0,0 +1,60 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class SpineSkin extends cc.Component {
@property(cc.Node)
addBoyBtn: cc.Node = null;
@property(cc.Node)
removeBoyBtn: cc.Node = null;
@property(cc.Node)
randomChangeBtn: cc.Node = null;
@property(cc.Node)
boy: cc.Node = null;
@property([cc.SpriteFrame])
heads: cc.SpriteFrame[] = [];
boys: cc.Node[] = [];
protected start(): void {
const boySpine = this.boy.getComponentInChildren(sp.Skeleton);
const newSkeletonData = boySpine.skeletonData.clone();
boySpine.skeletonData = newSkeletonData;
boySpine.animation = 'attack';
this.boys.push(this.boy);
this.addBoyBtn.on('click', () => {
const newBoy = cc.instantiate(this.boy);
const newBoySpine = newBoy.getComponentInChildren(sp.Skeleton);
boySpine.skeletonData = newBoySpine.skeletonData.clone();
boySpine.animation = 'attack';
this.boy.parent.addChild(newBoy);
newBoy.setPosition(this.boys[this.boys.length - 1].position);
newBoy.x += 100;
if (this.boys.length % 2 === 1) {
newBoy.getComponentInChildren(sp.Skeleton).setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE);
newBoy.getComponentInChildren(cc.Label).string = `Spine - Cache`;
}
this.boys.push(newBoy);
});
this.removeBoyBtn.on('click', () => {
if (this.boys.length > 1) {
this.boys[this.boys.length - 1].destroy();
this.boys.length -= 1;
}
});
this.randomChangeBtn.on('click', () => {
const boy = this.boys[this.boys.length - 1].getComponentInChildren(sp.Skeleton);
boy.setRegion('Head', 'Head', sp.SkeletonData.createRegion(this.heads[Math.floor(Math.random() * (this.heads.length))]));
});
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "27990422-853f-43c5-a2c7-52900cb9edef",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "4650da5c-d240-4ce6-b314-9e896888dd88",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@@ -0,0 +1,209 @@
huatuo.png
size: 701,208
format: RGBA8888
filter: Linear,Linear
repeat: none
Body
rotate: false
xy: 487, 72
size: 90, 91
orig: 90, 91
offset: 0, 0
index: -1
Eye
rotate: false
xy: 473, 44
size: 45, 24
orig: 45, 24
offset: 0, 0
index: -1
Eye-beiji
rotate: false
xy: 360, 60
size: 57, 23
orig: 57, 23
offset: 0, 0
index: -1
Eye-fennu
rotate: false
xy: 570, 39
size: 39, 21
orig: 39, 21
offset: 0, 0
index: -1
Eye-shengli
rotate: false
xy: 421, 64
size: 45, 19
orig: 45, 19
offset: 0, 0
index: -1
Eye-siwang
rotate: false
xy: 522, 48
size: 44, 20
orig: 44, 20
offset: 0, 0
index: -1
Head
rotate: false
xy: 581, 64
size: 89, 99
orig: 89, 99
offset: 0, 0
index: -1
L-Forearm
rotate: false
xy: 613, 29
size: 32, 31
orig: 32, 31
offset: 0, 0
index: -1
L-Hand
rotate: false
xy: 674, 150
size: 27, 26
orig: 27, 26
offset: 0, 0
index: -1
L-Lowerleg
rotate: false
xy: 674, 117
size: 26, 29
orig: 26, 29
offset: 0, 0
index: -1
L-Thigh
rotate: false
xy: 649, 25
size: 29, 35
orig: 29, 35
offset: 0, 0
index: -1
L-Upperarm
rotate: false
xy: 318, 7
size: 50, 49
orig: 50, 49
offset: 0, 0
index: -1
Mouth
rotate: false
xy: 682, 36
size: 18, 10
orig: 18, 10
offset: 0, 0
index: -1
Mouth-beiji
rotate: false
xy: 470, 72
size: 13, 11
orig: 13, 11
offset: 0, 0
index: -1
Mouth-fennu
rotate: false
xy: 674, 66
size: 22, 17
orig: 22, 17
offset: 0, 0
index: -1
Mouth-shengli
rotate: false
xy: 581, 17
size: 20, 18
orig: 20, 18
offset: 0, 0
index: -1
Mouth-siwang
rotate: false
xy: 682, 50
size: 18, 12
orig: 18, 12
offset: 0, 0
index: -1
Pelvis
rotate: false
xy: 641, 180
size: 43, 28
orig: 43, 28
offset: 0, 0
index: -1
R-Forearm
rotate: false
xy: 473, 9
size: 38, 31
orig: 38, 31
offset: 0, 0
index: -1
R-Hand
rotate: false
xy: 549, 12
size: 28, 23
orig: 28, 23
offset: 0, 0
index: -1
R-Lowerleg
rotate: false
xy: 674, 87
size: 26, 26
orig: 26, 26
offset: 0, 0
index: -1
R-Thigh
rotate: false
xy: 515, 4
size: 30, 36
orig: 30, 36
offset: 0, 0
index: -1
R-Upperarm
rotate: false
xy: 431, 12
size: 38, 48
orig: 38, 48
offset: 0, 0
index: -1
SE-daoguang
rotate: false
xy: 0, 0
size: 239, 208
orig: 239, 208
offset: 0, 0
index: -1
SE-guang
rotate: false
xy: 360, 87
size: 123, 121
orig: 123, 121
offset: 0, 0
index: -1
Weapon
rotate: false
xy: 243, 10
size: 71, 46
orig: 71, 46
offset: 0, 0
index: -1
beilou
rotate: false
xy: 243, 60
size: 113, 148
orig: 113, 148
offset: 0, 0
index: -1
hulu
rotate: false
xy: 372, 4
size: 55, 52
orig: 55, 52
offset: 0, 0
index: -1
shadow
rotate: false
xy: 487, 167
size: 150, 41
orig: 150, 41
offset: 0, 0
index: -1

View File

@@ -0,0 +1,5 @@
{
"ver": "1.0.1",
"uuid": "69163ff4-f84e-4d78-8ea7-946f62007fcd",
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.3",
"uuid": "9374ce8a-ae46-427f-9760-3694307fb4fa",
"textures": [
"804e11b5-bf4f-4a78-ac4a-8443e7166be1"
],
"scale": 1,
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "804e11b5-bf4f-4a78-ac4a-8443e7166be1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 701,
"height": 208,
"platformSettings": {},
"subMetas": {
"huatuo": {
"ver": "1.0.4",
"uuid": "b539b334-af1d-460c-a18d-de4e55947d2c",
"rawTextureUuid": "804e11b5-bf4f-4a78-ac4a-8443e7166be1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 2.5,
"offsetY": 0,
"trimX": 5,
"trimY": 0,
"width": 696,
"height": 208,
"rawWidth": 701,
"rawHeight": 208,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
import { chars } from "../chars";
const { ccclass, property } = cc._decorator;
@ccclass
export default class CharMode extends cc.Component {
@property(cc.Label)
bitmapFont1: cc.Label = null;
@property(cc.Label)
bitmapFont2: cc.Label = null;
@property(cc.Label)
bitmapFont3: cc.Label = null;
@property(cc.Label)
charFont1: cc.Label = null;
@property(cc.Label)
charFont2: cc.Label = null;
@property(cc.Label)
charFont3: cc.Label = null;
protected onLoad(): void {
this.bitmapFont1.string = this.getRandomText(15);
this.bitmapFont2.string = this.getRandomText(15);
this.bitmapFont3.string = this.getRandomText(15);
this.charFont1.string = this.getRandomText(15);
this.charFont2.string = this.getRandomText(15);
this.charFont3.string = this.getRandomText(15);
this.schedule(() => {
this.bitmapFont1.string = this.getRandomText(15);
this.bitmapFont2.string = this.getRandomText(15);
this.bitmapFont3.string = this.getRandomText(15);
this.charFont1.string = this.getRandomText(15);
this.charFont2.string = this.getRandomText(15);
this.charFont3.string = this.getRandomText(15);
}, 0.1);
}
getRandomText(length: number) {
let str = '';
while (str.length < length) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "59d30214-6082-40ab-96d5-2704f05b10b5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "0f37373d-8dc4-40cb-a343-5e7761491c53",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "0574009e-3e43-4b85-a325-89f9dede6c68",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "e267c12a-39ac-41db-9e97-de8e196c296d",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}