Commit d9cfdf1f authored by asdf's avatar asdf

完成功能

parent 17b50018
{
"ver": "1.1.2",
"uuid": "baa17bd2-3214-41ed-8a86-f64677160ad1",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "animDark",
"_objFlags": 0,
"_native": "",
"_duration": 0.016666666666666666,
"sample": 60,
"speed": 0.4,
"wrapMode": 1,
"curveData": {
"paths": {
"bg/bg_stardark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "0ea1bc39-9ee3-4378-b7b5-0a637fff01aa"
}
}
]
}
}
},
"bg/bg_moondark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "48f7c98b-5357-489f-a521-2cd6a62abde8"
}
}
]
}
}
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "a396ac09-978d-481b-a0e3-997a51f4678a",
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "animation",
"_objFlags": 0,
"_native": "",
"_duration": 0.016666666666666666,
"sample": 60,
"speed": 0.4,
"wrapMode": 1,
"curveData": {
"paths": {
"bg/bg_stardark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "3fc433b2-da4c-4aa2-bc03-1d202e971134"
}
}
]
}
}
},
"bg/bg_moondark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "4ec3fc3d-35c2-4cde-af8c-52536d71c6d3"
}
}
]
}
}
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "20c8555e-3c4c-4d3e-b35a-afc1720cdfdb",
"subMetas": {}
}
\ No newline at end of file
{"name":"NewProject_2","isGlobal":0,"version":"5.5","armature":[{"name":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"slot":[{"name":"图层_2","color":{},"parent":"root"},{"name":"眼1","displayIndex":2,"color":{},"z":1,"parent":"眼1"}],"bone":[{"name":"root","transform":{}},{"name":"眼1","transform":{"x":13.2,"y":-38.85},"parent":"root"}],"aabb":{"x":-68,"height":181,"y":-87,"width":131},"frameRate":24,"animation":[{"name":"newAnimation","frame":[],"duration":44,"slot":[{"name":"图层_2","colorFrame":[],"displayFrame":[]},{"name":"眼1","colorFrame":[],"displayFrame":[{"duration":20},{"duration":2},{"value":1,"duration":2},{"value":2,"duration":2},{"value":1,"duration":2},{"duration":16},{"duration":0}]}],"bone":[{"name":"root","scaleFrame":[],"translateFrame":[],"rotateFrame":[]},{"name":"眼1","scaleFrame":[],"translateFrame":[],"rotateFrame":[]}],"playTimes":0,"ffd":[],"ik":[]}],"type":"Armature","skin":[{"name":"","slot":[{"name":"图层_2","display":[{"name":"测试骨骼/图层_2","transform":{"x":-2.5,"y":3.5},"type":"image","path":"测试骨骼/图层_2"}]},{"name":"眼1","display":[{"name":"测试骨骼/眼1","transform":{"x":-14.7,"y":-1.65},"type":"image","path":"测试骨骼/眼1"},{"name":"测试骨骼/眼2","transform":{"x":-14.7,"y":-1.65},"type":"image","path":"测试骨骼/眼2"},{"name":"测试骨骼/眼3","transform":{"x":-14.7,"y":-1.65},"type":"image","path":"测试骨骼/眼3"}]}]}]}],"frameRate":24}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "e1623214-88d6-4d1e-a124-6d36cb382bce",
"subMetas": {}
}
\ No newline at end of file
{"name":"NewProject_2","SubTexture":[{"name":"测试骨骼/图层_2","x":1,"height":181,"y":1,"width":131},{"name":"测试骨骼/眼3","x":1,"height":15,"y":201,"width":43},{"name":"测试骨骼/眼2","x":1,"height":15,"y":218,"width":43},{"name":"测试骨骼/眼1","x":1,"height":15,"y":184,"width":43}],"imagePath":"NewProject_2_tex.png","height":256,"width":256}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "4791f23e-a9c9-4e6f-9366-55004bc2890a",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e5e9c399-69f4-45a9-a41a-c751768e0aff",
"uuid": "7029a1cf-56e3-49b4-976d-5919e29829f9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 192,
"height": 132,
"width": 256,
"height": 256,
"platformSettings": {},
"subMetas": {
"bg_ti2": {
"NewProject_2_tex": {
"ver": "1.0.4",
"uuid": "0afe36ba-5d72-49c4-94c7-60d858f60ca2",
"rawTextureUuid": "e5e9c399-69f4-45a9-a41a-c751768e0aff",
"uuid": "f621ad8c-a101-4f46-a241-46985d60f980",
"rawTextureUuid": "7029a1cf-56e3-49b4-976d-5919e29829f9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 0,
"offsetX": -61.5,
"offsetY": 11,
"trimX": 1,
"trimY": 1,
"width": 191,
"height": 130,
"rawWidth": 192,
"rawHeight": 132,
"width": 131,
"height": 232,
"rawWidth": 256,
"rawHeight": 256,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
......@@ -22,16 +22,22 @@
},
{
"__id__": 5
},
{
"__id__": 8
},
{
"__id__": 11
}
],
"_active": true,
"_components": [
{
"__id__": 8
"__id__": 14
}
],
"_prefab": {
"__id__": 9
"__id__": 15
},
"_opacity": 255,
"_color": {
......@@ -55,7 +61,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-472.5,
-465,
0,
0,
0,
......@@ -120,7 +126,7 @@
"ctor": "Float64Array",
"array": [
0,
-53.464,
-59.135,
0,
0,
0,
......@@ -189,7 +195,7 @@
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_name": "dragonBone",
"_objFlags": 0,
"_parent": {
"__id__": 1
......@@ -212,6 +218,117 @@
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 131,
"height": 181
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
40.781,
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__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "",
"_animationName": "",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "e1623214-88d6-4d1e-a124-6d36cb382bce#4791f23e-a9c9-4e6f-9366-55004bc2890a",
"_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": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b125237b-1bc1-4ec8-9b7b-60c16e96c5ae"
},
"fileId": "776VL7shBKgrZcDDncGnvr",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
}
],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 97.87,
......@@ -227,7 +344,7 @@
"ctor": "Float64Array",
"array": [
0,
0,
-5.671,
0,
0,
0,
......@@ -256,7 +373,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
"__id__": 8
},
"_enabled": true,
"_materials": [
......@@ -296,6 +413,113 @@
"fileId": "98kpAv+6RPI6x75ze5gWIu",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "bg_light",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 12
}
],
"_prefab": {
"__id__": 13
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 333,
"height": 137
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-152.903,
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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "519076d5-bab7-4250-acf9-bcfcf6d2a9af"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b125237b-1bc1-4ec8-9b7b-60c16e96c5ae"
},
"fileId": "3d73OiHzxCPoDl3F8SILEe",
"sync": false
},
{
"__type__": "c7c4a6NgRBL1LYik/VyDNVL",
"_name": "",
......@@ -312,9 +536,24 @@
"__uuid__": "9f52edb8-ef14-4027-9fb7-547d454c5707"
}
],
"sprBg": {
"__id__": 3
},
"labText": {
"__id__": 9
},
"nodLight": {
"__id__": 11
},
"dragonBone": {
"__id__": 6
},
"audRight": {
"__uuid__": "3aeb3c97-e4a2-4f0f-a479-48b8eeb6eeed"
},
"audWrong": {
"__uuid__": "169e45bc-9858-4f55-8020-667f6e4563c6"
},
"_id": ""
},
{
......
......@@ -21,20 +21,26 @@
"__id__": 2
},
{
"__id__": 5
"__id__": 7
},
{
"__id__": 10
}
],
"_active": true,
"_components": [
{
"__id__": 25
"__id__": 30
},
{
"__id__": 26
"__id__": 31
},
{
"__id__": 32
}
],
"_prefab": {
"__id__": 27
"__id__": 33
},
"_opacity": 255,
"_color": {
......@@ -54,6 +60,76 @@
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
640,
360,
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": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 6
},
"_opacity": 134,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 720
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
......@@ -83,6 +159,86 @@
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_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": 1280,
"_originalHeight": 720,
"_id": ""
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "682b8457-d696-4a22-8994-8ad61c414f1e"
},
"fileId": "2fBzmee0hC0KA/5EhZ4RR0",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "bg_verygood",
......@@ -94,11 +250,11 @@
"_active": true,
"_components": [
{
"__id__": 3
"__id__": 8
}
],
"_prefab": {
"__id__": 4
"__id__": 9
},
"_opacity": 255,
"_color": {
......@@ -152,7 +308,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
"__id__": 7
},
"_enabled": true,
"_materials": [
......@@ -199,28 +355,28 @@
},
"_children": [
{
"__id__": 6
"__id__": 11
},
{
"__id__": 9
"__id__": 14
},
{
"__id__": 12
"__id__": 17
},
{
"__id__": 15
"__id__": 20
},
{
"__id__": 18
"__id__": 23
},
{
"__id__": 21
"__id__": 26
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 24
"__id__": 29
},
"_opacity": 255,
"_color": {
......@@ -274,17 +430,17 @@
"_name": "bg_sahua",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
"__id__": 12
}
],
"_prefab": {
"__id__": 8
"__id__": 13
},
"_opacity": 255,
"_color": {
......@@ -338,7 +494,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 11
},
"_enabled": true,
"_materials": [
......@@ -381,17 +537,17 @@
"_name": "bg_sahua",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 10
"__id__": 15
}
],
"_prefab": {
"__id__": 11
"__id__": 16
},
"_opacity": 255,
"_color": {
......@@ -445,7 +601,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
"__id__": 14
},
"_enabled": true,
"_materials": [
......@@ -488,17 +644,17 @@
"_name": "bg_sahua",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
"__id__": 18
}
],
"_prefab": {
"__id__": 14
"__id__": 19
},
"_opacity": 255,
"_color": {
......@@ -552,7 +708,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
"__id__": 17
},
"_enabled": true,
"_materials": [
......@@ -595,17 +751,17 @@
"_name": "bg_sahua",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 16
"__id__": 21
}
],
"_prefab": {
"__id__": 17
"__id__": 22
},
"_opacity": 255,
"_color": {
......@@ -659,7 +815,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
"__id__": 20
},
"_enabled": true,
"_materials": [
......@@ -702,17 +858,17 @@
"_name": "bg_sahua",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 19
"__id__": 24
}
],
"_prefab": {
"__id__": 20
"__id__": 25
},
"_opacity": 255,
"_color": {
......@@ -766,7 +922,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 18
"__id__": 23
},
"_enabled": true,
"_materials": [
......@@ -809,17 +965,17 @@
"_name": "bg_sahua",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 22
"__id__": 27
}
],
"_prefab": {
"__id__": 23
"__id__": 28
},
"_opacity": 255,
"_color": {
......@@ -873,7 +1029,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 21
"__id__": 26
},
"_enabled": true,
"_materials": [
......@@ -941,6 +1097,36 @@
"__id__": 1
},
"_enabled": true,
"audOver": {
"__uuid__": "c92eebf4-6f1f-4608-af47-a6277311de3f"
},
"_id": ""
},
{
"__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": 1280,
"_originalHeight": 720,
"_id": ""
},
{
......
This diff is collapsed.
......@@ -2,18 +2,128 @@ cc.Class({
extends: cc.Component,
properties: {
spfBase:[cc.SpriteFrame],
labText:cc.Label,
spfBase: [cc.SpriteFrame],
sprBg: cc.Sprite,
labText: cc.Label,
nodLight: cc.Node,
dragonBone: dragonBones.ArmatureDisplay,
audRight: cc.AudioClip,
audWrong: cc.AudioClip,
},
// onLoad () {},
start () {
start() {
},
setInfo(data,index){
onEnable() {
this.node.on('touchstart', this.onTouchStart, this);
},
onDisable() {
this.node.off('touchstart', this.onTouchStart, this);
},
onTouchStart() {
if (GameData.isAudio) {
return;
}
if (GameData.currOptionIndex == this.index) {
this.chooseRight();
} else {
this.chooseWrong();
}
},
setInfo(data, index, scene, optionCount) {
this.scene = scene;
this.data = data;
this.index = index;
this.labText.string = index;
this.loadDragonBone();
if (optionCount == 3) {
this.sprBg.spriteFrame = this.spfBase[0];
} else {
this.sprBg.spriteFrame = this.spfBase[1];
}
},
loadDragonBone() {
GameData.dragonBoneCount++;
this.dragonBone.dragonAtlasAsset = null;
this.dragonBone.dragonAsset = null;
this.dragonBone.armatureName = '';
var imageUrl = this.data.optionDragonBone.texPngData.url;
var skeUrl = this.data.optionDragonBone.skeJsonData.url;
var atlasUrl = this.data.optionDragonBone.texJsonData.url;
// imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
// skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
// atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) {
console.log(error)
}
else {
cc.assetManager.loadRemote(imageUrl, (error, texture) => {
if (error) {
console.log(error)
}
else {
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas._uuid = atlasUrl;
atlas.atlasJson = assets[0];
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset._uuid = skeUrl;
asset.dragonBonesJson = assets[1];
this.dragonBone.dragonAtlasAsset = atlas;
this.dragonBone.dragonAsset = asset;
let data = asset._dragonBonesJsonData.armature[0];
if (!data) {
return;
}
this.dragonBone.armatureName = data.name;
this.animationName = data.animation[0].name;
GameData.dragonBoneCount--;
if (GameData.dragonBoneCount == 0) {
this.dragonBone.premultipliedAlpha = true;
atlas.texture.setPremultiplyAlpha(true);
}
}
});
}
});
},
chooseRight() {
this.node.zIndex = 5;
this.playAudioRight();
this.nodLight.active = true;
this.scene.moveToQuestion(this);
},
chooseWrong() {
this.playAudioWrong();
cc.tween(this.node)
.to(0.2, { y: -150 })
.to(0.2, { y: 0 })
.start()
},
playAudioRight() {
GameData.isAudio = true;
let id = cc.audioEngine.play(this.audRight, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.isAudio = false;
})
},
playAudioWrong() {
GameData.isAudio = true;
let id = cc.audioEngine.play(this.audWrong, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.isAudio = false;
})
},
// update (dt) {},
});
......@@ -2,18 +2,182 @@ cc.Class({
extends: cc.Component,
properties: {
nodBg1:cc.Node,
nodBg2:cc.Node,
labText:cc.Label,
nodBg1: cc.Node,
nodBg2: cc.Node,
dragonBone: dragonBones.ArmatureDisplay,
labText: cc.Label,
labQuestion1: cc.Label,
labQuestion2: cc.Label,
labQuestion3: cc.Label,
},
// onLoad () {},
start () {
start() {
},
setInfo(data,index){
onEnable() {
this.node.on('touchstart', this.onTouchStart, this);
},
onDisable() {
this.node.off('touchstart', this.onTouchStart, this);
},
setInfo(data, index, scene) {
this.scene = scene;
this.data = data;
this.index = index;
this.labText.string = index;
this.updateLabels();
this.loadDragonBone();
},
loadDragonBone() {
GameData.dragonBoneCount++;
this.dragonBone.dragonAtlasAsset = null;
this.dragonBone.dragonAsset = null;
this.dragonBone.armatureName = '';
var imageUrl = this.data.optionDragonBone.texPngData.url;
var skeUrl = this.data.optionDragonBone.skeJsonData.url;
var atlasUrl = this.data.optionDragonBone.texJsonData.url;
// imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
// skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
// atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
// imageUrl = 'http://127.0.0.1/walkingfish_tex.png';
// skeUrl = 'http://127.0.0.1/walkingfish_ske.json';
// atlasUrl = 'http://127.0.0.1/walkingfish_tex.json';
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) {
console.log(error)
}
else {
cc.assetManager.loadRemote(imageUrl, (error, texture) => {
if (error) {
console.log(error)
}
else {
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas._uuid = atlasUrl;
atlas.atlasJson = assets[0];
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset._uuid = skeUrl;
asset.dragonBonesJson = assets[1];
this.dragonBone.dragonAtlasAsset = atlas;
this.dragonBone.dragonAsset = asset;
let data = asset._dragonBonesJsonData.armature[0];
if (!data) {
return;
}
this.dragonBone.armatureName = data.name;
this.animationName = data.animation[0].name;
GameData.dragonBoneCount--;
if (GameData.dragonBoneCount == 0) {
this.dragonBone.premultipliedAlpha = true;
atlas.texture.setPremultiplyAlpha(true);
}
}
});
}
});
},
updateLabels() {
this.labQuestion1.string = this.data.text;
this.labQuestion2.string = this.data.text;
this.labQuestion3.string = this.data.text;
this.labQuestion1._forceUpdateRenderData();
this.labQuestion2._forceUpdateRenderData();
this.labQuestion3._forceUpdateRenderData();
if (this.labQuestion1.node.width > 145) {
this.labQuestion1.node.scale = 145 / this.labQuestion1.node.width;
this.labQuestion2.node.scale = 145 / this.labQuestion1.node.width;
this.labQuestion3.node.scale = 145 / this.labQuestion1.node.width;
}
},
setChooseRight(dragonBone, animationName) {
this.isRight = true;
this.animationName2 = animationName;
this.nodBg1.active = false;
this.nodBg2.active = true;
this.labQuestion1.node.parent.active = false;
this.labQuestion2.node.parent.active = false;
this.labQuestion3.node.active = true;
this.nodDragonBone2 = cc.instantiate(dragonBone.node);
this.nodDragonBone2.parent = this.node;
this.nodDragonBone2.x = 40;
this.nodDragonBone2.y = this.dragonBone.node.y;
this.dragonBone.node.x = -40;
this.playAudioOption(true);
this.dragonBone.playAnimation(this.animationName, 0);
this.nodDragonBone2.getComponent(dragonBones.ArmatureDisplay).playAnimation(animationName, 0);
},
stopRightAnimation() {
this.dragonBone.playAnimation(this.animationName, 1);
this.nodDragonBone2.getComponent(dragonBones.ArmatureDisplay).playAnimation(this.animationName2, 1);
},
setGray() {
this.isGray = true;
this.labQuestion1.node.parent.active = false;
this.labQuestion2.node.parent.active = false;
this.nodBg1.color = new cc.Color().fromHEX('#7E7E7E');
this.dragonBone.node.color = new cc.Color().fromHEX('#7E7E7E');
},
setNormal() {
this.isGray = false;
this.nodBg1.color = new cc.Color().fromHEX('#ffffff');
this.dragonBone.node.color = new cc.Color().fromHEX('#ffffff');
},
onTouchStart() {
if (this.isRight) {
return;
}
if (this.isGray) {
return;
}
if (GameData.isAudio) {
return;
}
this.showQipao();
this.playAudioOption();
},
showQipao() {
if (this.index == 3) {
this.labQuestion1.node.parent.active = false;
this.labQuestion2.node.parent.active = true;
} else {
this.labQuestion1.node.parent.active = true;
this.labQuestion2.node.parent.active = false;
}
},
playAudioOption(showNext) {
GameData.isAudio = true;
let url = this.data.optionAudio;
// url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
let id = cc.audioEngine.play(clip, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.isAudio = false;
if (showNext) {
this.scene.showNext(this.index);
}
})
});
},
// update (dt) {},
});
......@@ -4,16 +4,16 @@ cc.Class({
extends: cc.Component,
properties: {
audOver:cc.AudioClip,
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
onLoad() {
this.node.getChildByName('bg_verygood').zIndex = 99;
},
start () {
start() {
showFireworks(
this.node,
this.node.getChildByName('RibbonNodeBase').children,
......@@ -29,7 +29,15 @@ cc.Class({
this.node.getChildByName('RibbonNodeBase').children,
cc.v2(600, -400), cc.v2(-200, 1000), 200, 200
);
this.playAudioOver();
},
playAudioOver() {
GameData.isAudio = true;
let id = cc.audioEngine.play(this.audOver, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.isAudio = false;
})
},
// update (dt) {},
});
......@@ -6,8 +6,12 @@ cc.Class({
properties: {
audEnter: cc.AudioClip,
audMove: cc.AudioClip,
audMerge: cc.AudioClip,
audClick: cc.AudioClip,
pfbItemAnswer: cc.Prefab,
pfbItemQuestion: cc.Prefab,
layerOver: cc.Prefab,
},
// 生命周期 onLoad
......@@ -108,6 +112,11 @@ cc.Class({
loadEnd() {
GameData.questionIndex = 0;
this.questionList = [];
for (let i = 0; i < this.data.questionList.length; i++) {
this.questionList[i] = i;
}
this.initData();
this.startGame();
......@@ -115,27 +124,20 @@ cc.Class({
initData() {
// 所有全局变量 默认都是null
GameData.questionIndex = 0;
this.initQuestionASpace();
let optionList = this.data.questionList[GameData.questionIndex].optionList;
this.optionList = [];
for (let i = 0; i < optionList.length; i++) {
this.optionList[i] = i;
}
this.initQuestionAndAnswer();
this.initTitle();
this.updateBtnStatus();
},
startGame() {
this.playAudioEntrer();
},
initQuestionASpace() {
let optionList = this.data.questionList[GameData.questionIndex].optionList;
if (optionList.length == 3) {
this.nodeDict.nodQuestionParent.getComponent(cc.Layout).spacingX = 56;
this.nodeDict.nodAnswerParent.getComponent(cc.Layout).spacingX = 56;
} else {
this.nodeDict.nodQuestionParent.getComponent(cc.Layout).spacingX = 10;
this.nodeDict.nodAnswerParent.getComponent(cc.Layout).spacingX = 10;
}
},
initTitle() {
let label = this.nodeDict.labTitle.getComponent(cc.Label);
label.string = this.data.questionList[GameData.questionIndex].questionText;
......@@ -148,17 +150,40 @@ cc.Class({
// 初始化题干以及选项
initQuestionAndAnswer() {
let optionList = this.data.questionList[GameData.questionIndex].optionList;
let answerIndexs = [1, 2, 3];
if (optionList.length == 4) {
answerIndexs = [1, 2, 3, 4];
}
for (let i = 0; i < optionList.length; i++) {
let question = cc.instantiate(this.pfbItemQuestion);
question.parent = this.nodeDict.nodQuestionParent;
question.getComponent('ItemQuestion').setInfo(optionList[i], i);
question.x = this.getItemX(optionList, i);
let ItemQuestion = question.getComponent('ItemQuestion');
ItemQuestion.setInfo(optionList[i], i, this);
ItemQuestion.setGray();
let answer = cc.instantiate(this.pfbItemAnswer);
answer.parent = this.nodeDict.nodAnswerParent;
answer.getComponent('ItemAnswer').setInfo(optionList[i], i);
let index = Math.floor(Math.random() * answerIndexs.length)
answer.x = this.getItemX(optionList, answerIndexs[index] - 1);
answerIndexs.splice(index, 1);
answer.getComponent('ItemAnswer').setInfo(optionList[i], i, this, optionList.length);
}
},
getItemX(optionList, index) {
let itemWidth = 300;
let space = 10;
let x = index * (itemWidth + space) - 1.5 * (itemWidth + space);
if (optionList.length == 3) {
space = 56;
x = index * (itemWidth + space) - 1 * (itemWidth + space);
}
return x;
},
playAudioEntrer() {
GameData.isAudio = true;
let id = cc.audioEngine.play(this.audEnter, false, 1);
......@@ -185,9 +210,123 @@ cc.Class({
})
});
},
playAudioMove() {
GameData.isAudio = true;
let id = cc.audioEngine.play(this.audMove, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.isAudio = false;
})
},
playAudioMerge() {
GameData.isAudio = true;
let id = cc.audioEngine.play(this.audMerge, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.isAudio = false;
})
},
// 随机亮起一个题干
showRandomQuestion() {
GameData.currOptionIndex = this.optionList[Math.floor(Math.random() * this.optionList.length)]
let question = this.nodeDict.nodQuestionParent.children[GameData.currOptionIndex];
let ItemQuestion = question.getComponent('ItemQuestion');
ItemQuestion.setNormal();
ItemQuestion.showQipao();
ItemQuestion.playAudioOption();
},
showNext(index) {
for (let i = 0; i < this.optionList.length; i++) {
if (this.optionList[i] == index) {
this.optionList.splice(i, 1);
break;
}
}
if (this.optionList.length == 0) {
this.checkOver();
} else {
this.showRandomQuestion();
}
},
checkOver() {
for (let i = 0; i < this.questionList.length; i++) {
if (this.questionList[i] == GameData.questionIndex) {
this.questionList.splice(i, 1);
break;
}
}
if (this.questionList.length == 0) {
let node = cc.instantiate(this.layerOver);
node.parent = this.node;
}
},
moveToQuestion(ItemAnswer) {
let index = ItemAnswer.index;
let question = this.nodeDict.nodQuestionParent.children[index];
let pos = this.nodeDict.nodQuestionParent.convertToWorldSpaceAR(question.position);
pos = this.nodeDict.nodAnswerParent.convertToNodeSpaceAR(pos);
this.playAudioMove();
cc.tween(ItemAnswer.node)
.to(0.8, { position: pos })
.call(() => {
question.getComponent('ItemQuestion').setChooseRight(ItemAnswer.dragonBone, ItemAnswer.animationName);
ItemAnswer.node.destroy();
this.getComponent(cc.Animation).play('animLight');
this.playAudioMerge();
cc.tween(question)
.delay(3)
.call(() => {
question.getComponent('ItemQuestion').stopRightAnimation();
this.getComponent(cc.Animation).play('animDark');
})
.start()
})
.start()
},
updateBtnStatus() {
if (GameData.questionIndex == 0) {
this.nodeDict.btnLast.getComponent(cc.Button).interactable = false;
} else{
this.nodeDict.btnLast.getComponent(cc.Button).interactable = true;
}
if (GameData.questionIndex == this.data.questionList.length - 1) {
this.nodeDict.btnNext.getComponent(cc.Button).interactable = false;
}else{
this.nodeDict.btnNext.getComponent(cc.Button).interactable = true;
}
},
onTurnLast() {
if (GameData.isAudio) {
return;
}
GameData.questionIndex--;
this.nodeDict.nodAnswerParent.destroyAllChildren();
this.nodeDict.nodQuestionParent.destroyAllChildren();
this.initData();
this.playAudioQuestion();
},
onReplay() {
if (GameData.isAudio) {
return;
}
this.nodeDict.nodAnswerParent.destroyAllChildren();
this.nodeDict.nodQuestionParent.destroyAllChildren();
this.initData();
this.startGame();
},
onTurnNext() {
if (GameData.isAudio) {
return;
}
GameData.questionIndex++;
this.nodeDict.nodAnswerParent.destroyAllChildren();
this.nodeDict.nodQuestionParent.destroyAllChildren();
this.initData();
this.startGame();
},
buttonListener(button) {
......@@ -195,6 +334,12 @@ cc.Class({
if (!GameData.isAudio) {
this.playAudioQuestion();
}
} else if (button.node.name == 'btnLast') {
this.onTurnLast();
} else if (button.node.name == 'btnReplay') {
this.onReplay();
} else if (button.node.name == 'btnNext') {
this.onTurnNext();
}
},
......
{
"ver": "2.3.5",
"uuid": "b13600b5-1c1d-4ac0-a08c-e5b1c15c4143",
"uuid": "e4a27dab-8f93-4903-8f57-dfbb42bac7cb",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"width": 44,
"height": 46,
"platformSettings": {},
"subMetas": {
"7-三道题布局": {
"invalid-name_10": {
"ver": "1.0.4",
"uuid": "4137ea3f-52bc-4e96-95fc-d48662170d82",
"rawTextureUuid": "b13600b5-1c1d-4ac0-a08c-e5b1c15c4143",
"uuid": "4047aa89-66ac-44a8-ad53-b819f6e57e6b",
"rawTextureUuid": "e4a27dab-8f93-4903-8f57-dfbb42bac7cb",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"width": 44,
"height": 46,
"rawWidth": 44,
"rawHeight": 46,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "1d37d614-b7cb-4ec6-8cbb-c9d798dc7a14",
"uuid": "7eeefab0-9f99-4750-8ceb-402ebcff4d8d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"width": 47,
"height": 57,
"platformSettings": {},
"subMetas": {
"4-移动到一起后,两个底座消失变成大底座,同时开始播放两个骨骼动画和音频,音频播完一边停止,动画一直循环播放背景星星和月亮亮持续3秒左右)": {
"invalid-name_8": {
"ver": "1.0.4",
"uuid": "7f9056d6-161e-49a1-877b-17eab0c61558",
"rawTextureUuid": "1d37d614-b7cb-4ec6-8cbb-c9d798dc7a14",
"uuid": "fd890cbc-1219-416a-91be-4d41d42089b7",
"rawTextureUuid": "7eeefab0-9f99-4750-8ceb-402ebcff4d8d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"width": 47,
"height": 57,
"rawWidth": 47,
"rawHeight": 57,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "1c19823e-1e2c-4d3d-9a83-143947f0b808",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 45,
"height": 46,
"platformSettings": {},
"subMetas": {
"invalid-name_9": {
"ver": "1.0.4",
"uuid": "9d036708-92d8-4a7f-8732-118d056f8fd4",
"rawTextureUuid": "1c19823e-1e2c-4d3d-9a83-143947f0b808",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 45,
"height": 46,
"rawWidth": 45,
"rawHeight": 46,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
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