Commit d0fe6be8 authored by 李维's avatar 李维

复制ET04项目

parent 9f5f5457
No preview for this file type
......@@ -2,8 +2,6 @@
cocos creator技术框架下的H5互动模板框架脚手架,基于cocos creator实现快速开发基于绘玩云的H5互动课件。
[视频教程传送门](https://www.bilibili.com/video/BV1Dq4y1t7n5/)
# 使用简介
## 前期准备
......@@ -50,8 +48,22 @@ npm install
npm start
```
* 打开浏览器:http://staging-teach.ireadabc.com/template_ci/debug
* [点击查看调试视频教程](https://www.bilibili.com/video/BV1Dq4y1t7n5?p=8)
* 打开浏览器:http://staging-teach.ireadabc.com/template_ci/debug
* 点击右上角齿轮,选择技术选型、调试模式选择“普通”
### 互动模板
* 找到项目根路径下 index.html 文件
* 在引入JS的位置将air.js改为air_online_open.js
* 启动本地服务
```
npm start
```
* 打开浏览器:http://staging-teach.ireadabc.com/template_ci/debug
* 点击右上角齿轮,选择技术选型、调试模式选择“互动”
* 左侧老师、右侧学生
### 真机调试
......@@ -69,11 +81,42 @@ npm start
* 手机和电脑连接同一个Wifi
* 打开调试app,根据提示输入IP地址,点击开始就可以在手机上预览模板了
* 使用 console.log("==调试信息=="); 可以打印日志进行必要的调试
* 点击左上角 “logcat” 可以查看运行日志,(logcat是可以按住拖动的, 所以不用考虑UI遮挡问题)
* 使用 this.log("==调试信息=="); 可以打印日志进行必要的调试
### 关于联机模板
* 网络连接相关的代码位置:
assets/script/NetworkHelper.ts
* 服务器相关代码位置:
assets/script/Server.ts
### 注意事项及常见问题
* AI相关代码位置:
assets/script/AI.ts
* 注意要将以下代码中的"op_16"参数改为自己的模板名称
```
this.networkHelper.init("op_16", 2);
```
* 项目里所有文件及文件夹的命名方式要注意不能包含空格、汉字、减号
* 项目里尽量不要使用setTimeout、setInterval等定时器,如果使用了记得在onDestroy中释放掉(onDestroy 是指CocosCreator的生命周期钩子)
* 理论上禁止使用全局变量,因为模板到线上会进行组装,常见问题是一个模板使用多次造成全局变量被读脏
* 联机对战引擎文档:
https://cloud.tencent.com/document/product/629/46678
https://cloud.tencent.com/document/product/1038/50849
### 联机模板额外的验收标准
* 联机功能可用
* 无人联机时,需要自动填充AI
* 有人掉线时,需弹出提示,让玩家自行选择退出或重开游戏
### 关于op_16的说明:
* 通信接口
SERVER_allPlayerInfo: 由server发给player,有玩家加入或离开时发送,用来更新玩家信息。
SERVER_updateStatus: 由server发给player,更新游戏状态,主要是回合结束换边等。
SERVER_playerRoll: 由server发给player,玩家转动转盘。
SERVER_playerRight: 由server发给player,玩家选择了正确的格子。
SERVER_playerWrong: 由server发给player,玩家选择了错误的格子。
SERVER_playerWin: 由server发给player,玩家胜利。
roll: player发送给server,玩家试图转动转盘。
right: player发送给server,玩家选择了正确的格子。
wrong: player发送给server,玩家选择了错误的格子。
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "4afb4ea2-dbff-426e-90e8-7914df4ddc1f",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "icon_sound_finish",
"_objFlags": 0,
"_native": "",
"_duration": 0.016666666666666666,
"sample": 60,
"speed": 1,
"wrapMode": 1,
"curveData": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "781a51f6-3297-47ba-ad00-9a418e7f9e95"
}
}
]
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "06152c30-b640-4a64-93a8-3adab0429e3a",
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "icon_sound_play",
"_objFlags": 0,
"_native": "",
"_duration": 0.5166666666666667,
"sample": 60,
"speed": 0.35,
"wrapMode": 2,
"curveData": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "c82ef682-cd88-4c26-9f9d-03101a4e051a"
}
},
{
"frame": 0.16666666666666666,
"value": {
"__uuid__": "3f3aea8b-ba65-40fb-b2db-d6b8ea8c8e32"
}
},
{
"frame": 0.3333333333333333,
"value": {
"__uuid__": "79b2a0cf-aff5-43de-80ac-64430d5ac188"
}
},
{
"frame": 0.5,
"value": {
"__uuid__": "c82ef682-cd88-4c26-9f9d-03101a4e051a"
}
}
]
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "a3cd73a9-d35f-40cb-a50a-d57eb80cde64",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "f7ba93b1-0719-40f3-8482-0d5d94a2fb8f",
"downloadMode": 0,
"duration": 3.787755,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "684d7cb6-2589-4ca9-97e4-4fee3d611cdc",
"downloadMode": 0,
"duration": 1.854694,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "5060d073-9761-4a5c-8910-5439b56725bf",
"downloadMode": 0,
"duration": 2.324917,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c271a59a-d4e5-453e-8e2e-5b97fa3e4b43",
"downloadMode": 0,
"duration": 0.556563,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "f074d2b6-91fb-457f-bc83-93ffa39a7ca3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "477a4289-7aea-4116-b80f-d3719a5a0191",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 64,
"height": 64,
"platformSettings": {},
"subMetas": {
"particle": {
"ver": "1.0.4",
"uuid": "a20aecd1-ff1b-458d-a4e2-13cf79681ff6",
"rawTextureUuid": "477a4289-7aea-4116-b80f-d3719a5a0191",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1.5,
"offsetY": 1.5,
"trimX": 12,
"trimY": 10,
"width": 37,
"height": 41,
"rawWidth": 64,
"rawHeight": 64,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>angle</key>
<real>17</real>
<key>angleVariance</key>
<real>180</real>
<key>blendFuncDestination</key>
<integer>1</integer>
<key>blendFuncSource</key>
<integer>768</integer>
<key>duration</key>
<real>0.22</real>
<key>emitterType</key>
<real>0</real>
<key>finishColorAlpha</key>
<real>1</real>
<key>finishColorBlue</key>
<real>0</real>
<key>finishColorGreen</key>
<real>0</real>
<key>finishColorRed</key>
<real>0</real>
<key>finishColorVarianceAlpha</key>
<real>0</real>
<key>finishColorVarianceBlue</key>
<real>0</real>
<key>finishColorVarianceGreen</key>
<real>0</real>
<key>finishColorVarianceRed</key>
<real>0</real>
<key>finishParticleSize</key>
<real>-1</real>
<key>finishParticleSizeVariance</key>
<real>0</real>
<key>gravityx</key>
<real>-20</real>
<key>gravityy</key>
<real>420</real>
<key>maxParticles</key>
<real>191</real>
<key>maxRadius</key>
<real>0</real>
<key>maxRadiusVariance</key>
<real>0</real>
<key>minRadius</key>
<real>0</real>
<key>particleLifespan</key>
<real>0.47</real>
<key>particleLifespanVariance</key>
<real>0</real>
<key>radialAccelVariance</key>
<real>0</real>
<key>radialAcceleration</key>
<real>0</real>
<key>rotatePerSecond</key>
<real>0</real>
<key>rotatePerSecondVariance</key>
<real>0</real>
<key>rotationEnd</key>
<real>0</real>
<key>rotationEndVariance</key>
<real>0.0</real>
<key>rotationStart</key>
<real>0</real>
<key>rotationStartVariance</key>
<real>0</real>
<key>sourcePositionVariancex</key>
<real>0</real>
<key>sourcePositionVariancey</key>
<real>0</real>
<key>sourcePositionx</key>
<real>416</real>
<key>sourcePositiony</key>
<real>774</real>
<key>speed</key>
<real>480</real>
<key>speedVariance</key>
<real>20</real>
<key>startColorAlpha</key>
<real>0.89</real>
<key>startColorBlue</key>
<real>0.2</real>
<key>startColorGreen</key>
<real>0.4</real>
<key>startColorRed</key>
<real>1</real>
<key>startColorVarianceAlpha</key>
<real>0</real>
<key>startColorVarianceBlue</key>
<real>0</real>
<key>startColorVarianceGreen</key>
<real>0</real>
<key>startColorVarianceRed</key>
<real>0</real>
<key>startParticleSize</key>
<real>20</real>
<key>startParticleSizeVariance</key>
<real>41</real>
<key>tangentialAccelVariance</key>
<real>0</real>
<key>tangentialAcceleration</key>
<real>-700</real>
<key>textureFileName</key>
<string>particle_star.png</string>
<key>textureImageData</key>
<string></string>
</dict>
</plist>
{
"ver": "2.0.1",
"uuid": "986c8cea-3186-454a-865b-c818da543819",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "3a8508c6-3d78-4768-b77e-9d6b00a918b0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 366,
"height": 336,
"width": 37,
"height": 36,
"platformSettings": {},
"subMetas": {
"1orange": {
"particle_star": {
"ver": "1.0.4",
"uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa",
"rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "539cc31f-1963-46f3-9f0f-fb8f5658c54e",
"rawTextureUuid": "3a8508c6-3d78-4768-b77e-9d6b00a918b0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"offsetY": 0,
"trimX": 0,
"trimY": 1,
"width": 366,
"height": 335,
"rawWidth": 366,
"rawHeight": 336,
"trimY": 0,
"width": 37,
"height": 36,
"rawWidth": 37,
"rawHeight": 36,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>angle</key>
<real>253.41999816894531</real>
<key>angleVariance</key>
<real>0.0</real>
<key>blendFuncDestination</key>
<integer>771</integer>
<key>blendFuncSource</key>
<integer>1</integer>
<key>duration</key>
<real>-1</real>
<key>emitterType</key>
<real>0.0</real>
<key>finishColorAlpha</key>
<real>1</real>
<key>finishColorBlue</key>
<real>1</real>
<key>finishColorGreen</key>
<real>1</real>
<key>finishColorRed</key>
<real>1</real>
<key>finishColorVarianceAlpha</key>
<real>0</real>
<key>finishColorVarianceBlue</key>
<real>1</real>
<key>finishColorVarianceGreen</key>
<real>1</real>
<key>finishColorVarianceRed</key>
<real>1</real>
<key>finishParticleSize</key>
<real>30</real>
<key>finishParticleSizeVariance</key>
<real>10</real>
<key>gravityx</key>
<real>0.0</real>
<key>gravityy</key>
<real>-100.54499816894531</real>
<key>maxParticles</key>
<real>400</real>
<key>maxRadius</key>
<real>100</real>
<key>maxRadiusVariance</key>
<real>0.0</real>
<key>minRadius</key>
<real>0.0</real>
<key>particleLifespan</key>
<real>5</real>
<key>particleLifespanVariance</key>
<real>0.0</real>
<key>radialAccelVariance</key>
<real>0.0</real>
<key>radialAcceleration</key>
<real>0.0</real>
<key>rotatePerSecond</key>
<real>0.0</real>
<key>rotatePerSecondVariance</key>
<real>0.0</real>
<key>rotationEnd</key>
<real>804.1529541015625</real>
<key>rotationEndVariance</key>
<real>-3600</real>
<key>rotationStart</key>
<real>450.37005615234375</real>
<key>rotationStartVariance</key>
<real>-1270.0657958984375</real>
<key>sourcePositionVariancex</key>
<real>1088</real>
<key>sourcePositionVariancey</key>
<real>0.0</real>
<key>sourcePositionx</key>
<real>384</real>
<key>sourcePositiony</key>
<real>785.88232421875</real>
<key>speed</key>
<real>100</real>
<key>speedVariance</key>
<real>300</real>
<key>startColorAlpha</key>
<real>1</real>
<key>startColorBlue</key>
<real>1</real>
<key>startColorGreen</key>
<real>1</real>
<key>startColorRed</key>
<real>1</real>
<key>startColorVarianceAlpha</key>
<real>0</real>
<key>startColorVarianceBlue</key>
<real>1</real>
<key>startColorVarianceGreen</key>
<real>1</real>
<key>startColorVarianceRed</key>
<real>1</real>
<key>startParticleSize</key>
<real>30</real>
<key>startParticleSizeVariance</key>
<real>10</real>
<key>tangentialAccelVariance</key>
<real>0.0</real>
<key>tangentialAcceleration</key>
<real>0.0</real>
<key>textureFileName</key>
<string>particle.png</string>
</dict>
</plist>
{
"ver": "2.0.1",
"uuid": "538af702-8a0f-4265-beb1-be7a0f687356",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"uuid": "daae9bc9-d3a9-4d5a-8b08-d39bd5a958da",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 144,
"height": 144,
"width": 120,
"height": 120,
"platformSettings": {},
"subMetas": {
"icon": {
"sui": {
"ver": "1.0.4",
"uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a",
"rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"uuid": "fb6b1982-4305-4b8a-a83e-04ac25732105",
"rawTextureUuid": "daae9bc9-d3a9-4d5a-8b08-d39bd5a958da",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 3,
"trimY": 2,
"width": 138,
"height": 141,
"rawWidth": 144,
"rawHeight": 144,
"offsetX": 0.5,
"offsetY": 0.5,
"trimX": 1,
"trimY": 3,
"width": 119,
"height": 113,
"rawWidth": 120,
"rawHeight": 120,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "1.1.2",
"uuid": "2d185f4f-99df-463e-8487-d01a392b994b",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "op_pic",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": {
"__id__": 13
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 256,
"height": 227
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
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": 2,
"groupIndex": 2,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "pic_frame_selected",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 232,
"g": 67,
"b": 29,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 256,
"height": 219
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-1,
0,
0,
0,
0,
1,
1.06,
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__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "dec1094e-44d7-400e-ae82-87256133f537"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b74714cb-b4ed-49a6-9955-c21a7c47db01"
},
"fileId": "2dGGITfL1FmLu4WXaq1ijO",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "pic_frame",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_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": 256,
"height": 227
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
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__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "7fea9c73-91cb-4f14-b9e9-0ba62035d742"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b74714cb-b4ed-49a6-9955-c21a7c47db01"
},
"fileId": "6dq18PWx1CippwCfwZboH5",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "sprite",
"_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": 168,
"height": 168
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
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__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_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.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b74714cb-b4ed-49a6-9955-c21a7c47db01"
},
"fileId": "16DPpqsdpDG4Q1+EyiNkvS",
"sync": false
},
{
"__type__": "cc.BoxCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"tag": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_size": {
"__type__": "cc.Size",
"width": 102,
"height": 102
},
"_id": ""
},
{
"__type__": "4d2edZVlmVH06BDADL/ukha",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"pic": {
"__id__": 9
},
"pic_selected": {
"__id__": 2
},
"sounds": [
{
"__uuid__": "5060d073-9761-4a5c-8910-5439b56725bf"
},
{
"__uuid__": "c271a59a-d4e5-453e-8e2e-5b97fa3e4b43"
}
],
"_opId": 0,
"_ori_pos": null,
"_isEnter": false,
"_isContact": false,
"_soundOp": null,
"_picUrl": null,
"_spriteFrame": null,
"_width": null,
"_height": null,
"_isMoved": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b74714cb-b4ed-49a6-9955-c21a7c47db01"
},
"fileId": "efzBFwsVZFIpLDtBguWA5C",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "b74714cb-b4ed-49a6-9955-c21a7c47db01",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "f816bebc-d7fa-41ca-aa93-efe1af15931d",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "particle_star",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
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.ParticleSystem",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_custom": true,
"_file": {
"__uuid__": "986c8cea-3186-454a-865b-c818da543819"
},
"_spriteFrame": {
"__uuid__": "539cc31f-1963-46f3-9f0f-fb8f5658c54e"
},
"_texture": null,
"_stopped": true,
"playOnLoad": true,
"autoRemoveOnFinish": true,
"totalParticles": 191,
"duration": 0.22,
"emissionRate": 200,
"life": 0.47,
"lifeVar": 0.6,
"_startColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_startColorVar": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_endColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_endColorVar": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"angle": -180,
"angleVar": 180,
"startSize": 10,
"startSizeVar": 30,
"endSize": -1,
"endSizeVar": 0,
"startSpin": 0,
"startSpinVar": 180,
"endSpin": 0,
"endSpinVar": 180,
"sourcePos": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"posVar": {
"__type__": "cc.Vec2",
"x": 100,
"y": 100
},
"_positionType": 1,
"positionType": 1,
"emitterMode": 0,
"gravity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 120
},
"speed": 20,
"speedVar": 220,
"tangentialAccel": 0,
"tangentialAccelVar": 0,
"radialAccel": 0,
"radialAccelVar": 0,
"rotationIsDir": false,
"startRadius": 0,
"startRadiusVar": 0,
"endRadius": 0,
"endRadiusVar": 0,
"rotatePerS": 0,
"rotatePerSVar": 0,
"_N$preview": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "b6qTzZ+GtJjpvXdRXuot9u",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "de39730a-d6dc-4031-9744-9ca5c01fc1f0",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "sui",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
571,
247,
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.ParticleSystem",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_custom": true,
"_file": {
"__uuid__": "538af702-8a0f-4265-beb1-be7a0f687356"
},
"_spriteFrame": {
"__uuid__": "fb6b1982-4305-4b8a-a83e-04ac25732105"
},
"_texture": null,
"_stopped": false,
"playOnLoad": true,
"autoRemoveOnFinish": false,
"totalParticles": 300,
"duration": -1,
"emissionRate": 80,
"life": 5,
"lifeVar": 0,
"_startColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_startColorVar": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 0
},
"_endColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_endColorVar": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 0
},
"angle": 253.4199981689453,
"angleVar": 0,
"startSize": 30,
"startSizeVar": 10,
"endSize": 30,
"endSizeVar": 10,
"startSpin": 450.37005615234375,
"startSpinVar": -1270.0657958984375,
"endSpin": 804.1529541015625,
"endSpinVar": -3600,
"sourcePos": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"posVar": {
"__type__": "cc.Vec2",
"x": 1088,
"y": 0
},
"_positionType": 1,
"positionType": 1,
"emitterMode": 0,
"gravity": {
"__type__": "cc.Vec2",
"x": 0,
"y": -100.54499816894531
},
"speed": 100,
"speedVar": 300,
"tangentialAccel": 0,
"tangentialAccelVar": 0,
"radialAccel": 0,
"radialAccelVar": 0,
"rotationIsDir": false,
"startRadius": 0,
"startRadiusVar": 0,
"endRadius": 0,
"endRadiusVar": 0,
"rotatePerS": 0,
"rotatePerSVar": 0,
"_N$preview": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "43HhlK8MBA455Uic/ufNlS",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "d30b053b-c7eb-4811-951c-01c98b5825bf",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"uuid": "57ea7c61-9b8b-498a-b024-c98ee9124beb",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "f8b451ff-857c-4ca8-9870-866bc5154a29",
"uuid": "f4ede462-f8d7-4069-ba80-915611c058ca",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
/**
* 选项,图片
*/
cc.Class({
extends: cc.Component,
properties: {
// 图片
pic: {
default: null,
type: cc.Sprite,
},
// 图片选中底图
pic_selected: {
default: null,
type: cc.Node,
},
// 声音,0-正确,1-错误
sounds: {
default: [],
type: [cc.AudioClip],
},
_opId: 0, // 选项id
_ori_pos: null, // 初始位置
_isEnter: false, // 是否碰到对的选框
_isContact: false, // 是否碰到了选项框
_soundOp: null, // 碰到的选框
_picUrl: null, // 图片地址
_spriteFrame: null,
_width: null,
_height: null,
_isMoved: false,
_scale: 1,
},
onEnable() {
cc.game.on("SELECT", this.selected, this);
},
onDisable() {
cc.game.off("SELECT", this.selected, this);
},
onLoad() {
this.scheduleOnce(function () {
this._ori_pos = this.node.getPosition();
}, 0.5);
this.node.on("touchstart", this.onTouchStart, this);
this.node.on("touchmove", this.onTouchMove, this);
this.node.on("touchend", this.onTouchEnd, this);
this.node.on("touchcancel", this.onTouchEnd, this);
},
setPic() {
cc.loader.load({ url: this._picUrl }, (err, img) => {
let frame = new cc.SpriteFrame(img);
let frameSize = frame.getOriginalSize();
this._spriteFrame = frame;
let scale = 1;
if (frameSize.height > 168) {
scale = 168 / frameSize.height;
}
this.pic.spriteFrame = frame;
this.pic.node.width = frameSize.width * scale;
this.pic.node.height = frameSize.height * scale;
scale = 1;
if (frameSize.width > 168) {
scale = 168 / frameSize.width;
}
this.pic.node.width = frameSize.width * scale;
this.pic.node.height = frameSize.height * scale;
this._width = this.pic.node.width;
this._height = this.pic.node.height;
});
},
onTouchStart(event) {
this.pic_selected.active = true;
cc.game.emit("SELECT", this._opId);
},
//触摸移动;
onTouchMove(touch, event) {
let delta = touch.getDelta();
this.node.x += delta.x / this._scale;
this.node.y += delta.y / this._scale;
this._isMoved = true;
},
onTouchEnd() {
if (this._isContact && !this._soundOp.node.getComponent("op_sound")._isRight) {
if (this._isEnter) {
console.log("enter right");
cc.game.emit("STOP_ALL_AUDIO");
this.playSound(0);
this._soundOp.node.getComponent("op_sound").correct(this._spriteFrame, this._width, this._height);
this.node.destroy();
} else {
console.log("enter false");
cc.game.emit("STOP_ALL_AUDIO");
this.playSound(1);
this.node.active = false;
this._soundOp.node.getComponent("op_sound").wrong(this._spriteFrame, this._width, this._height);
}
} else {
this.node.setPosition(this._ori_pos);
}
if (this._isMoved) {
this._isMoved = false;
this.pic_selected.active = false;
}
},
/**
* 当碰撞产生的时候调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionEnter: function (other, self) {
console.log("on collision");
this._soundOp = other;
this._isContact = true;
if (other.getComponent("op_sound")._opId == this._opId) {
this._isEnter = true;
}
},
/**
* 当碰撞结束后调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionExit: function (other, self) {
console.log("on collision exit");
this._isEnter = false;
this._isContact = false;
},
// 播放声音
playSound(index) {
cc.audioEngine.playEffect(this.sounds[index], false);
},
resetPos() {
this.node.setPosition(this._ori_pos);
},
selected(id) {
if (this._opId == id) {
return;
}
this.pic_selected.active = false;
},
});
{
"ver": "1.0.8",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5",
"uuid": "4d2ed655-9665-47d3-a043-0032ffba485a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
/**
* 选项框(带播放按钮)
*/
cc.Class({
extends: cc.Component,
properties: {
// 声音图标
iconSound: {
default: null,
type: cc.Node,
},
// 声音图标
rightFrame: {
default: null,
type: cc.Node,
},
// 声音图标
rightPic: {
default: null,
type: cc.Sprite,
},
// 星星特效
particle_star: {
default: null,
type: cc.Prefab,
},
_opId: 0, // 选项id
_soundUrl: "", // 音频文件地址
_opPic: null,
_isRight: false,
_isPlaying: false,
_curAudioId: 0,
},
onEnable() {
cc.game.on("STOP_ALL_AUDIO", this.onStopAudio, this);
},
onDisable() {
cc.game.off("STOP_ALL_AUDIO", this.onStopAudio, this);
},
/**
* 播放声音
*/
play() {
if (this._soundUrl != "" && !this._isPlaying) {
cc.game.emit("STOP_ALL_AUDIO");
this._isPlaying = true;
cc.assetManager.loadRemote(this._soundUrl, (err, audioClip) => {
this._curAudioId = cc.audioEngine.play(audioClip, false);
this.iconSound.getComponent(cc.Animation).play("icon_sound_play");
cc.audioEngine.setFinishCallback(this._curAudioId, () => {
this.iconSound.getComponent(cc.Animation).play("icon_sound_finish");
this._isPlaying = false;
});
});
}
},
/**
* 当碰撞产生的时候调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionEnter: function (other, self) {
this._opPic = other;
},
/**
* 当碰撞结束后调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionExit: function (other, self) {
console.log("on collision exit");
},
correct(spriteFrame, width, height) {
this.rightFrame.active = true;
this.rightPic.node.width = width;
this.rightPic.node.height = height;
this.rightPic.spriteFrame = spriteFrame;
var par = cc.instantiate(this.particle_star);
this.node.addChild(par);
this._isRight = true;
cc.game.emit("RIGHT");
},
wrong(spriteFrame, width, height) {
this.rightFrame.active = true;
this.rightPic.node.width = width;
this.rightPic.node.height = height;
this.rightPic.spriteFrame = spriteFrame;
let time = 0.05;
let action = cc.repeat(
cc.sequence(cc.moveBy(time, -10, 0), cc.moveBy(time, 10, 0), cc.moveBy(time, 10, 0), cc.moveBy(time, -10, 0)),
4
);
this.node.runAction(action);
this.scheduleOnce(function () {
this.rightFrame.active = false;
this.rightPic.spriteFrame = null;
this._opPic.node.active = true;
this._opPic.node.getComponent("op_pic").resetPos();
}, 1.2);
},
onStopAudio() {
if (this._isPlaying) {
this._isPlaying = false;
this.iconSound.getComponent(cc.Animation).play("icon_sound_finish");
cc.audioEngine.stopEffect(this._curAudioId);
}
},
});
{
"ver": "1.0.8",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"uuid": "d7d8bebe-bc59-4281-a878-76bdefddd326",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor(180 / (Math.PI / radina) * 100) / 100; // 将弧度转换成角度
if (mx > px && my > py) {// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {// 鼠标在第二象限
angle = 360 - angle;
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export function setSprNodeMaxLen(sprNode, maxW, maxH) {
const sx = maxW / sprNode.width;
const sy = maxH / sprNode.height;
const s = Math.min(sx, sy);
sprNode.scale = Math.round(s * 1000) / 1000;
}
export function localPosTolocalPos(baseNode, targetNode) {
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function worldPosToLocalPos(worldPos, baseNode) {
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height;
if (maxFlag) {
return Math.max(sx, sy);
} else {
return Math.min(sx, sy);
}
}
export function getDistance (start, end){
var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x*pos.x + pos.y*pos.y);
return dis;
}
export function playAudioByUrl(audio_url, cb=null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}
}
export function btnClickAnima(btn, time=0.15, rate=1.05) {
btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.scale * rate})
.start()
})
btn.on(cc.Node.EventType.TOUCH_CANCEL, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.start()
})
btn.on(cc.Node.EventType.TOUCH_END, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.start()
})
}
\ No newline at end of file
export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor(180 / (Math.PI / radina) * 100) / 100; // 将弧度转换成角度
if (mx > px && my > py) {// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {// 鼠标在第二象限
angle = 360 - angle;
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
export function Between(a, b, c) {
return [a, b, c].sort((a, b) => a - b)[1];
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncPlayDragonBoneAnimation(node, animationName, time = 1, onFrameEvent) {
return new Promise((resolve, reject) => {
node.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve();
});
node.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof (onFrameEvent) == 'function') {
onFrameEvent(name);
}
});
node.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time);
});
}
export async function asyncPlayEffectByUrl(url, loop = false) {
return new Promise((resolve, reject) => {
cc.assetManager.loadRemote(url, (err, clip) => {
console.log(clip);
cc.audioEngine.playEffect(clip, loop);
resolve();
});
});
}
export async function jelly(node) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 })
.to(0.1, { scaleX: 1, scaleY: 1 })
.call(resolve)
.start();
});
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, time * 1000);
})
}
export async function showFireworks(baseNode, nodeList, pos = cc.v2(0, 0), side = cc.v2(0, 100), range = 50, number = 100) {
new Array(number).fill(' ').forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
await asyncTweenBy(rabbonNode, 0.3, {
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate
}, {
easing: 'quadIn'
});
cc.tween(rabbonNode)
.by(8, { y: -2000 })
.start();
rabbonFall(rabbonNode);
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: offsetX * 60 / 200 });
rabbonFall(node);
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "d545f402-231b-417e-99e6-3269412a5a2c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e1b4d971-9876-4832-803a-5a321964a78b",
"uuid": "37b3a51d-5cb5-452e-9e88-80298ee56b2d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
......@@ -13,8 +13,8 @@
"subMetas": {
"bg": {
"ver": "1.0.4",
"uuid": "8288e3d4-4c75-4b27-8f01-f7014417f4dd",
"rawTextureUuid": "e1b4d971-9876-4832-803a-5a321964a78b",
"uuid": "b13d9316-4516-4589-aa68-e651e30a1713",
"rawTextureUuid": "37b3a51d-5cb5-452e-9e88-80298ee56b2d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......
{
"ver": "1.1.2",
"uuid": "cce0136e-5a05-4c7f-97ea-84476ae584cf",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "4567363d-dadd-42af-a2b9-4b3e7b1335a4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"width": 49,
"height": 50,
"platformSettings": {},
"subMetas": {
"btn_left": {
"3": {
"ver": "1.0.4",
"uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5",
"rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "781a51f6-3297-47ba-ad00-9a418e7f9e95",
"rawTextureUuid": "4567363d-dadd-42af-a2b9-4b3e7b1335a4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 61,
"height": 67,
"rawWidth": 61,
"rawHeight": 67,
"width": 49,
"height": 50,
"rawWidth": 49,
"rawHeight": 50,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "c1e07859-c7a6-4318-a34d-c1c765911ba2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 253,
"height": 218,
"platformSettings": {},
"subMetas": {
"frame": {
"ver": "1.0.4",
"uuid": "74dc9cd4-6dd0-4cef-9d6a-396b8322df20",
"rawTextureUuid": "c1e07859-c7a6-4318-a34d-c1c765911ba2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 253,
"height": 218,
"rawWidth": 253,
"rawHeight": 218,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b213d731-fc0b-4053-aee2-1c39eead5a22",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 74,
"height": 82,
"platformSettings": {},
"subMetas": {
"invalid-name": {
"ver": "1.0.4",
"uuid": "da197dd1-ff21-4ff1-9210-ac6bd41de4ec",
"rawTextureUuid": "b213d731-fc0b-4053-aee2-1c39eead5a22",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 74,
"height": 82,
"rawWidth": 74,
"rawHeight": 82,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "fcceafba-7ea2-42b3-b4b3-a2cc50f99b8b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 256,
"height": 227,
"platformSettings": {},
"subMetas": {
"pic_frame": {
"ver": "1.0.4",
"uuid": "7fea9c73-91cb-4f14-b9e9-0ba62035d742",
"rawTextureUuid": "fcceafba-7ea2-42b3-b4b3-a2cc50f99b8b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 0,
"trimX": 2,
"trimY": 0,
"width": 253,
"height": 227,
"rawWidth": 256,
"rawHeight": 227,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "641b2540-061f-44f6-9248-8ffa04efb6ce",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 256,
"height": 227,
"platformSettings": {},
"subMetas": {
"pic_frame_selected": {
"ver": "1.0.4",
"uuid": "dec1094e-44d7-400e-ae82-87256133f537",
"rawTextureUuid": "641b2540-061f-44f6-9248-8ffa04efb6ce",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 4,
"trimX": 2,
"trimY": 0,
"width": 253,
"height": 219,
"rawWidth": 256,
"rawHeight": 227,
"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",
"uuid": "819f263d-3b26-418a-b964-adaeb413f7fa",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"width": 32,
"height": 50,
"platformSettings": {},
"subMetas": {
"btn_right": {
"sound_0": {
"ver": "1.0.4",
"uuid": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59",
"rawTextureUuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"uuid": "c82ef682-cd88-4c26-9f9d-03101a4e051a",
"rawTextureUuid": "819f263d-3b26-418a-b964-adaeb413f7fa",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0.5,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 60,
"height": 66,
"rawWidth": 61,
"rawHeight": 67,
"width": 31,
"height": 50,
"rawWidth": 32,
"rawHeight": 50,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "535abe48-2513-441f-84ed-b5cfa71d6678",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 41,
"height": 50,
"platformSettings": {},
"subMetas": {
"sound_1": {
"ver": "1.0.4",
"uuid": "3f3aea8b-ba65-40fb-b2db-d6b8ea8c8e32",
"rawTextureUuid": "535abe48-2513-441f-84ed-b5cfa71d6678",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 41,
"height": 50,
"rawWidth": 41,
"rawHeight": 50,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "74fdf805-822d-4024-b332-ecb2397e2295",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 49,
"height": 50,
"platformSettings": {},
"subMetas": {
"sound_2": {
"ver": "1.0.4",
"uuid": "79b2a0cf-aff5-43de-80ac-64430d5ac188",
"rawTextureUuid": "74fdf805-822d-4024-b332-ecb2397e2295",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 49,
"height": 50,
"rawWidth": 49,
"rawHeight": 50,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "667882e6-45ce-4729-9ffd-6e5343343837",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 445,
"height": 105,
"platformSettings": {},
"subMetas": {
"title": {
"ver": "1.0.4",
"uuid": "419f91a3-c543-4570-bf49-cdb0234bcc9f",
"rawTextureUuid": "667882e6-45ce-4729-9ffd-6e5343343837",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 445,
"height": 105,
"rawWidth": 445,
"rawHeight": 105,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "14fad522-d449-45d9-9a76-8fd0f5bd60df",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "607805bf-3b7e-4de6-bce5-7a8df6fd9a31",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "b54300af-b8e5-4b4e-aa2f-9ac1cef7b598",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
const express = require('express');
const os = require('os');
const readline = require('readline');
const Base64 = require('js-base64');
const CryptoJS = require("crypto-js");
const http = require("http");
const { build, buildAndroid, buildIos } = require('./buildCocos');
const networkInfo = os.networkInterfaces();
......@@ -18,12 +21,58 @@ for (const infos of Object.values(networkInfo)) {
var app = express();
// Access-Control-Allow-Origin: *
app.use('/dist', express.static('dist'));
app.use('/form', express.static('form'));
app.get('/', function (req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.send('Hello World');
})
});
app.get('/getSign', function (req, res) {
res.header("Access-Control-Allow-Origin", "*");
const gameId = req.query.gameId;
const openId = req.query.openId;
const secretKey = "060d81c7abaf24c8ce2afc5a725c152062676d35"; //替换为控制台上的 游戏 Key
const nonce = Math.floor(Math.random() * 1000000000);
const timestamp = Math.floor(new Date().getTime() / 1000);
const str = `game_id=${gameId}&nonce=${nonce}&open_id=${openId}&timestamp=${timestamp}`;
const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(str, secretKey));
res.send(JSON.stringify({ nonce, timestamp, sign }));
});
// app.get('/jump', function (req, res) {
// res.header("Access-Control-Allow-Origin", "*");
// const gameId = req.query.gameId;
// const openId = req.query.openId;
// http.get({
// hostname: 'staging-teach.ireadabc.com',
// port: 80,
// path: `/api/oxford/game/v1/config?gameid=${gameId}&openid=${openId}`,
// agent: false // 仅为这个请求创建新代理
// }, (getres) => {
// getres.setEncoding('utf8');
// let rawData = '';
// getres.on('data', (chunk) => { rawData += chunk; });
// getres.on('end', () => {
// const secretKey = "060d81c7abaf24c8ce2afc5a725c152062676d35"; //替换为控制台上的 游戏 Key
// const data = JSON.parse(rawData);
// const str = `game_id=${gameId}&nonce=${data.nonce}&open_id=${openId}&timestamp=${data.timestamp}`;
// const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(str, secretKey));
// console.log('sign = ' + sign);
// res.send(rawData)
// });
// });
// });
let port = '';
var server = app.listen(8081, function () {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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