Commit 980900e4 authored by 李维's avatar 李维

完成

parent 60ce5e8c
......@@ -78,19 +78,34 @@
"__id__": 7
},
{
"__id__": 14
"__id__": 9
},
{
"__id__": 12
},
{
"__id__": 15
},
{
"__id__": 17
},
{
"__id__": 21
},
{
"__id__": 27
}
],
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 30
},
{
"__id__": 25
"__id__": 31
},
{
"__id__": 26
"__id__": 32
}
],
"_prefab": null,
......@@ -316,9 +331,7 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8288e3d4-4c75-4b27-8f01-f7014417f4dd"
},
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
......@@ -335,21 +348,18 @@
},
{
"__type__": "cc.Node",
"_name": "bottomPart",
"_name": "dbCanvas",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
"_children": [],
"_active": true,
"_components": [
{
"__id__": 8
},
{
"__id__": 11
}
],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
......@@ -361,8 +371,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
"width": 1280,
"height": 720
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -373,8 +383,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
635.132,
-356.326,
0,
75,
0,
0,
0,
......@@ -396,23 +406,55 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "8c7k8ep/ZFNpO263+1QHz9"
"_id": "318so1hOlOapTSrmmWHpDe"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8288e3d4-4c75-4b27-8f01-f7014417f4dd"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "beMRHvOO1HZ5qPIuNgb4/O"
},
{
"__type__": "cc.Node",
"_name": "btn_left",
"_name": "dragonBone",
"_objFlags": 0,
"_parent": {
"__id__": 7
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
"__id__": 10
},
{
"__id__": 10
"__id__": 11
}
],
"_prefab": null,
......@@ -426,8 +468,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 61,
"height": 67
"width": 1280,
"height": 570
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -438,8 +480,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-148.464,
34,
0,
75,
0,
0,
0,
......@@ -461,14 +503,14 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "5ad2wLQLxIN5Eg7OHecSH6"
"_id": "53r5vCx0FAeZl4lr7U/f5n"
},
{
"__type__": "cc.Sprite",
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 9
},
"_enabled": true,
"_materials": [
......@@ -476,108 +518,181 @@
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "84mqOgJ3JNqZrYVTEU8CjE"
"_armatureName": "",
"_animationName": "",
"_preCacheMode": -1,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": null,
"_N$dragonAtlasAsset": null,
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "33zo7sgWpCK6uigywBpJta"
},
{
"__type__": "cc.Button",
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 9
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 150,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "74s/83Q/RAab7JiBpKkJ22"
},
{
"__type__": "cc.Node",
"_name": "aniInfo",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
},
{
"__id__": 14
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 37.8
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 1
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-630,
-282.2,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "7cfv1YqrZE2JP8uH6aKttL"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "bcYN/4EKBJhbIAfovo9Ah1"
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 12,
"_left": 10,
"_right": 0,
"_top": 0,
"_bottom": 40,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 300,
"_originalHeight": 0,
"_id": "18UsAMNS9MXZjrN6E1lLsh"
},
{
"__type__": "cc.RichText",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"_fontFamily": "Arial",
"_isSystemFontUsed": true,
"_N$string": "",
"_N$horizontalAlign": 0,
"_N$fontSize": 24,
"_N$font": null,
"_N$cacheMode": 0,
"_N$maxWidth": 0,
"_N$lineHeight": 30,
"_N$imageAtlas": null,
"_N$handleTouchEvent": true,
"_id": "f8VdQu4shLcIynmCZ3al2s"
},
{
"__type__": "cc.Node",
"_name": "btn_right",
"_name": "btnSelAniGroup",
"_objFlags": 0,
"_parent": {
"__id__": 7
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 12
},
{
"__id__": 13
"__id__": 16
}
],
"_prefab": null,
......@@ -591,20 +706,20 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 60,
"height": 66
"width": 100,
"height": 50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
"x": 0,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-47.164,
34,
-630,
-260,
0,
0,
0,
......@@ -626,46 +741,109 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "46i3stdzpHX6zQHTGnRsNE"
"_id": "103TGGtKtFJLESfDgQg4bH"
},
{
"__type__": "cc.Sprite",
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
"__id__": 15
},
"_enabled": true,
"_materials": [
"alignMode": 1,
"_target": null,
"_alignFlags": 12,
"_left": 10,
"_right": 0,
"_top": 0,
"_bottom": 50,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "12iQFpUylGNpOpsj4lBzmO"
},
{
"__type__": "cc.Node",
"_name": "btnPlay",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": false,
"_components": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
"__id__": 18
},
{
"__id__": 19
},
{
"__id__": 20
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59"
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"_contentSize": {
"__type__": "cc.Size",
"width": 59,
"height": 59
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
560.5,
-280.5,
0,
0,
0,
0,
1,
1,
1,
0
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0
"y": 0,
"z": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "42Sh8QS/BHn4WiGyPQPKPt"
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "72jQpBWZRBmZfnMBStzawG"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
"__id__": 17
},
"_enabled": true,
"_normalMaterial": null,
......@@ -675,8 +853,8 @@
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
......@@ -726,7 +904,66 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "1aj32fYY1IxLesa77E70Qu"
"_id": "f2Rn894u1CE4Psm4TgRf2Y"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 36,
"_left": 50,
"_right": 50,
"_top": 0,
"_bottom": 50,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 59,
"_originalHeight": 0,
"_id": "2cPnJHLFZHdYhvJrXJva0R"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "51635c9c-e34f-4d2d-9446-fd003560ff39"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "52biOSoQJLnrO7c09kA6Jz"
},
{
"__type__": "cc.Node",
......@@ -737,13 +974,13 @@
},
"_children": [
{
"__id__": 15
"__id__": 22
},
{
"__id__": 18
"__id__": 25
},
{
"__id__": 21
"__id__": 26
}
],
"_active": false,
......@@ -801,11 +1038,11 @@
"_name": "font",
"_objFlags": 0,
"_parent": {
"__id__": 14
"__id__": 21
},
"_children": [
{
"__id__": 16
"__id__": 23
}
],
"_active": true,
......@@ -863,13 +1100,13 @@
"_name": "BRLNSDB",
"_objFlags": 0,
"_parent": {
"__id__": 15
"__id__": 22
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 17
"__id__": 24
}
],
"_prefab": null,
......@@ -925,7 +1162,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 23
},
"_enabled": true,
"_materials": [],
......@@ -956,13 +1193,9 @@
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 14
"__id__": 21
},
"_children": [
{
"__id__": 19
}
],
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
......@@ -1015,18 +1248,14 @@
},
{
"__type__": "cc.Node",
"_name": "icon",
"_name": "audio",
"_objFlags": 0,
"_parent": {
"__id__": 18
"__id__": 21
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 20
}
],
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
......@@ -1038,8 +1267,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 138,
"height": 141
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -1073,50 +1302,25 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "1blU2OArJIfoC9XfupGxJG"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 19
},
"_enabled": true,
"_materials": [],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "03GEWUEZJGyKormWgIWCtM"
"_id": "d9f+b0lmZGSJJae6zrADhp"
},
{
"__type__": "cc.Node",
"_name": "audio",
"_name": "aniSelBtn",
"_objFlags": 0,
"_parent": {
"__id__": 14
"__id__": 2
},
"_children": [
"_children": [],
"_active": false,
"_components": [
{
"__id__": 22
"__id__": 28
},
{
"__id__": 29
}
],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
......@@ -1128,13 +1332,13 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
"width": 122.27,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
"x": 0,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
......@@ -1163,88 +1367,108 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "d9f+b0lmZGSJJae6zrADhp"
"_id": "dbcKRZEFJItbtBRhBAhccm"
},
{
"__type__": "cc.Node",
"_name": "btn",
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"_parent": {
"__id__": 21
"node": {
"__id__": 27
},
"_children": [],
"_active": true,
"_components": [
"_enabled": true,
"_materials": [
{
"__id__": 23
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "normal",
"_N$string": "normal",
"_fontSize": 24,
"_lineHeight": 30,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 1,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "31/2DuV9tNEYg5ng9BhtuK"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 27
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "e87DSaFCVJfb2PAUkf4/o7"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 22
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_enabled": true,
"_clip": {
"__uuid__": "f0680ae0-c079-45ef-abd7-9e63d90b982b"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "dey05oKrBIspvsDa6pOIQz"
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "b1+oMRL4NCFYMnGLxs2TRd"
},
{
"__type__": "cc.Canvas",
......@@ -1298,6 +1522,18 @@
"__id__": 2
},
"_enabled": true,
"dragonBoneNode": {
"__id__": 9
},
"btnPlay": {
"__id__": 17
},
"aniInfo": {
"__id__": 12
},
"outlineBorder": {
"__id__": 7
},
"_id": "eaTVUpqahPfZeO9+sUI7RP"
}
]
\ No newline at end of file
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node)
dragonBoneNode: cc.Node = null;
@property(cc.Node)
btnPlay: cc.Node = null;
@property(cc.Node)
aniInfo: cc.Node = null;
@property(cc.Node)
outlineBorder: cc.Node = null;
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initGlobal();
this.loadDragonBoneAnim();
}
dragonDisplay = null;
initGlobal() {
// 初始化播放按钮
this.btnPlay.on("click", ()=>{
this.playDragBone(this.currentPlayAniName)
})
// 初始化骨骼动画
this.dragonDisplay = this.dragonBoneNode.getComponent(dragonBones.ArmatureDisplay);
}
currentAniData = null;
currentPlayAniName = null;
canvas = null;
loadDragonBoneAnim() {
let dbData = {
tex_png_url: "http://teach.cdn.ireadabc.com/a3f250a588c6c3e80683a00e9aa95e5d.png",
ske_json_url: "http://teach.cdn.ireadabc.com/e9193257f9158cdb0b655fa2c5554512.json",
tex_json_url: "http://teach.cdn.ireadabc.com/a97b1a41e874cc3ac56ed13106ee4a09.json",
}
const queryData = this.getQueryString("data");
if(queryData) {
dbData = JSON.parse(decodeURIComponent(queryData))
}
console.log(dbData)
const canvas = cc.find("Canvas")
return new Promise((resolve, reject) => {
cc.assetManager.loadAny([{ url: dbData.tex_json_url, ext: '.txt' }, { url: dbData.ske_json_url, ext: '.txt' }], (error, assets) => {
if (error) return resolve('');
if (dbData.tex_png_url == '') console.log(this.data)
cc.assetManager.loadRemote(dbData.tex_png_url, (error, texture) => {
if (error) return resolve('');
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = assets[0];
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = assets[1];
this.dragonDisplay.dragonAtlasAsset = atlas;
this.dragonDisplay.dragonAsset = asset;
let data = asset._dragonBonesJsonData.armature[0];
if (!data) return resolve('');
console.log(data)
this.currentAniData = data;
this.dragonDisplay.armatureName = data.name;
this.currentPlayAniName = data.animation[0].name;
this.dragonDisplay.animationName = this.currentPlayAniName;
const scaleX = canvas.width / data.canvas.width;
const scaleY = (canvas.height - 150) / data.canvas.height;
const scale = Math.min(scaleX, scaleY);
this.dragonBoneNode.scale = scale;
this.outlineBorder.width = data.canvas.width;
this.outlineBorder.height = data.canvas.height;
this.outlineBorder.scale = scale;
// this.dragonDisplay.premultipliedAlpha = true;
// atlas.texture.setPremultiplyAlpha(true);
this.updateDragonBoneInfo(this.currentAniData)
return resolve('');
});
});
});
}
createAniSelectButtons(buttonNames) {
const template = cc.find("Canvas/aniSelBtn")
const parent = cc.find("Canvas/btnSelAniGroup");
buttonNames.forEach((btnName, index) => {
const node = cc.instantiate(template);
node.getComponent(cc.Label).string = "播放:" + btnName;
node.on("click", ()=>{
this.playDragBone(btnName);
this.currentPlayAniName = btnName;
})
node.x = index * 150
node.active = true;
parent.addChild(node);
});
}
getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
updateDragonBoneInfo(data) {
let richtext = this.aniInfo.getComponent(cc.RichText);
let allAniNAme = [];
data.animation.forEach(ani => {
allAniNAme.push(ani.name)
});
this.createAniSelectButtons(allAniNAme);
// 默认播放
let defaultPlayAniName = null;
if(data.defaultActions && data.defaultActions.length>0) {
defaultPlayAniName = data.defaultActions[0].gotoAndPlay;
}
let templateStr = `<span>名称: ${data.name}</span> <span>默认播放:${defaultPlayAniName}</span> <span>帧率: ${data.frameRate}fps</span><br/>`;
templateStr += `<span>宽:${data.aabb.width}</span> <span>高:${data.aabb.height}</span> <span>画布宽:${data.canvas.width}</span> <span>画布高:${data.canvas.height}</span> <span>中心点x:${data.canvas.x}</span> <span>中心点y:${data.canvas.y}</span><br/>`;
richtext.string = templateStr;
}
playDragBone(aniName) {
this.dragonDisplay.playAnimation(aniName, 1);
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
{
"ver": "2.3.5",
"uuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "8f65080a-c298-4e66-8d85-b96b6bc7ef4d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"width": 128,
"height": 128,
"platformSettings": {},
"subMetas": {
"btn_left": {
"btn_play": {
"ver": "1.0.4",
"uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5",
"rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "51635c9c-e34f-4d2d-9446-fd003560ff39",
"rawTextureUuid": "8f65080a-c298-4e66-8d85-b96b6bc7ef4d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 61,
"height": 67,
"rawWidth": 61,
"rawHeight": 67,
"trimX": 5,
"trimY": 5,
"width": 118,
"height": 118,
"rawWidth": 128,
"rawHeight": 128,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
{
"ver": "2.3.5",
"uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 366,
"height": 336,
"platformSettings": {},
"subMetas": {
"1orange": {
"ver": "1.0.4",
"uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa",
"rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 0,
"trimY": 1,
"width": 366,
"height": 335,
"rawWidth": 366,
"rawHeight": 336,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"platformSettings": {},
"subMetas": {
"btn_right": {
"ver": "1.0.4",
"uuid": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59",
"rawTextureUuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0.5,
"trimX": 0,
"trimY": 0,
"width": 60,
"height": 66,
"rawWidth": 61,
"rawHeight": 67,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 144,
"height": 144,
"platformSettings": {},
"subMetas": {
"icon": {
"ver": "1.0.4",
"uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a",
"rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 3,
"trimY": 2,
"width": 138,
"height": 141,
"rawWidth": 144,
"rawHeight": 144,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
var fs = require('fs-extra');
var file = require('./util/file');
module.exports = {
load() {
},
unload() {
},
replaceDirUuid: function (path, dbpath) {
Editor.log('开始检查:' + path);
file.findDirUuid(path);
Editor.log('资源检查完成');
},
messages: {
'checkFileName'() {
var uuids = Editor.Selection.curSelection('asset');
uuids.forEach((uuid) => {
var dir_path = Editor.assetdb._uuid2path[uuid];
if (fs.existsSync(dir_path)) {
this.replaceDirUuid(dir_path, Editor.assetdb.uuidToUrl(uuid));
}
});
},
},
}
\ No newline at end of file
{
"name": "check-file-name",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "0.0.1",
"dependencies": {
"node-uuid": "1.4.8"
}
},
"node_modules/node-uuid": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz",
"integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=",
"deprecated": "Use uuid module instead",
"bin": {
"uuid": "bin/uuid"
}
}
},
"dependencies": {
"node-uuid": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz",
"integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc="
}
}
}
{
"name": "check-file-name",
"version": "0.0.1",
"description": "check-file-name",
"author": "Cocos Creator",
"main": "main.js",
"main-menu": {
"i18n:MAIN_MENU.package.title/check-file-name": {
"message": "check-file-name:checkFileName"
}
},
"dependencies": {
"node-uuid": "1.4.8"
}
}
var fs = require("fs-extra");
var path = require("path");
var AppName = ""
module.exports = {
/**
* 递归目录 检查文件名
* 参考 https://docs.cocos.com/creator/manual/zh/advanced-topics/meta.html
*/
findDirUuid: function (dir) {
if(AppName == '') {
AppName = this.getRootDirName(dir);
if(AppName != "") {
Editor.log("AppName: " + AppName);
}
}
var stat = fs.statSync(dir);
if (!stat.isDirectory()) {
return;
}
var subpaths = fs.readdirSync(dir),
subpath;
for (var i = 0; i < subpaths.length; ++i) {
if (subpaths[i][0] === ".") {
continue;
}
subpath = path.join(dir, subpaths[i]);
stat = fs.statSync(subpath);
if (stat.isDirectory()) {
this.findDirUuid(subpath);
} else if (stat.isFile()) {
var metastr = subpath.substr(subpath.length - 5, 5);
if (metastr != ".meta") {
this.check(AppName, subpaths[i]);
}
}
}
},
getRootDirName: function (path) {
let pArr = path.split("/");
let assteIndex = -1;
pArr.find((item, index) => {
if(item == 'assets') {
assteIndex = index;
return true
} else {
return false
}
})
if(assteIndex > 0 && assteIndex<(pArr.length-1)) {
return pArr[assteIndex + 1];
} else {
return ""
}
},
check: (appName, filePath) => {
if(escape(filePath).indexOf("%u")>=0) {
Editor.log(`检测到[中文或中文符号]命名的文件: ${filePath}`);
}
if (!/^\S*$/.test(filePath)) {
Editor.log(`检测到[包含空格]命名的文件: ${filePath}`);
}
if (/[-]/.test(filePath)) {
Editor.log(`检测到存在[包含减号(-)]命名的文件: ${filePath}`);
}
if(filePath.indexOf(appName) == -1 && (filePath.endsWith(".js") || filePath.endsWith(".ts"))) {
Editor.log(`检测到[不包含包名(${appName})]的文件: ${filePath}`);
}
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment