Commit fc887792 authored by liujiangnan's avatar liujiangnan

feat

parent 762ae1c9
...@@ -93,8 +93,8 @@ cc.Class({ ...@@ -93,8 +93,8 @@ cc.Class({
this.uid = res.uid; this.uid = res.uid;
// 测试数据 // 测试数据
this.role = 'audience'; this.role = 'anchor';
this.uid = 'student'; this.uid = 'teacher';
const nickObj = await drawOpenNickName(res.nickName); const nickObj = await drawOpenNickName(res.nickName);
......
...@@ -93,13 +93,13 @@ ...@@ -93,13 +93,13 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 89 "__id__": 100
}, },
{ {
"__id__": 90 "__id__": 101
}, },
{ {
"__id__": 91 "__id__": 102
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2447,19 +2447,22 @@ ...@@ -2447,19 +2447,22 @@
"__id__": 78 "__id__": 78
}, },
{ {
"__id__": 82 "__id__": 84
},
{
"__id__": 90
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 86 "__id__": 97
}, },
{ {
"__id__": 87 "__id__": 98
}, },
{ {
"__id__": 88 "__id__": 99
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3486,6 +3489,9 @@ ...@@ -3486,6 +3489,9 @@
"_components": [ "_components": [
{ {
"__id__": 81 "__id__": 81
},
{
"__id__": 82
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3663,6 +3669,88 @@ ...@@ -3663,6 +3669,88 @@
"_atlas": null, "_atlas": null,
"_id": "5a/bxN7yNCWqvN9jCsyz5H" "_id": "5a/bxN7yNCWqvN9jCsyz5H"
}, },
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 78
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 83
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "8aU61sJfdEX7W9oDzHBnkp"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 2
},
"component": "",
"_componentId": "408a6f4ZfpM8Yzyg+IOGg/V",
"handler": "restart",
"customEventData": ""
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "reset", "_name": "reset",
...@@ -3672,13 +3760,16 @@ ...@@ -3672,13 +3760,16 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 83 "__id__": 85
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 85 "__id__": 87
},
{
"__id__": 88
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3734,13 +3825,13 @@ ...@@ -3734,13 +3825,13 @@
"_name": "text", "_name": "text",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 82 "__id__": 84
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 84 "__id__": 86
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3796,7 +3887,7 @@ ...@@ -3796,7 +3887,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 83 "__id__": 85
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3829,7 +3920,7 @@ ...@@ -3829,7 +3920,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 82 "__id__": 84
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3856,6 +3947,345 @@ ...@@ -3856,6 +3947,345 @@
"_atlas": null, "_atlas": null,
"_id": "50FmKAM5dGibPdGcnu0v00" "_id": "50FmKAM5dGibPdGcnu0v00"
}, },
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 84
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 89
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "7bjQFrsQ1PIa1tBKV49Wf7"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 2
},
"component": "",
"_componentId": "408a6f4ZfpM8Yzyg+IOGg/V",
"handler": "reset",
"customEventData": ""
},
{
"__type__": "cc.Node",
"_name": "loading",
"_objFlags": 0,
"_parent": {
"__id__": 55
},
"_children": [
{
"__id__": 91
}
],
"_active": false,
"_components": [
{
"__id__": 94
},
{
"__id__": 95
},
{
"__id__": 96
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1920,
"height": 1080
},
"_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": "d9S/1IaR9H55vODMcPO2ow"
},
{
"__type__": "cc.Node",
"_name": "text",
"_objFlags": 0,
"_parent": {
"__id__": 90
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 92
},
{
"__id__": 93
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1173.2,
"height": 342.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-94.488,
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": "e3NabubORHfr1PNbydaHm2"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 91
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Loading...",
"_N$string": "Loading...",
"_fontSize": 240,
"_lineHeight": 240,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 1,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "07NjMXDKhLYbBFlMFK87VN"
},
{
"__type__": "cc.LabelOutline",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 91
},
"_enabled": true,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_width": 20,
"_id": "f6pIYh3gNFF5KRRhuyhjKR"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_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": "baQQzMul1Nd4gP4iYdvliO"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_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": 100,
"_originalHeight": 100,
"_id": "214yDeCG9P1Ys0i9vs+7ub"
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_enabled": true,
"_id": "cdYqZbT/VAp5uPVaI4uGT3"
},
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
...@@ -3983,6 +4413,9 @@ ...@@ -3983,6 +4413,9 @@
"rankTemplate": { "rankTemplate": {
"__id__": 58 "__id__": 58
}, },
"rankpage": {
"__id__": 55
},
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "eaTVUpqahPfZeO9+sUI7RP"
} }
] ]
\ No newline at end of file
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import { getRoomId, asyncCallNetworkApiGet } from "../../douyin_xiaoxiaole/script/supportToolsDy"; import { getRoomId, asyncCallNetworkApiGet } from "../../douyin_xiaoxiaole/script/supportToolsDy";
import { asyncDelay } from "../../douyin_xiaoxiaole/script/hw_elimination_letter_util";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -12,6 +13,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -12,6 +13,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node) @property(cc.Node)
rankTemplate: cc.Node = null; rankTemplate: cc.Node = null;
@property(cc.Node)
rankpage: cc.Node = null;
addPreloadImage() { addPreloadImage() {
} }
...@@ -34,41 +38,39 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -34,41 +38,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
async initView() { async initView() {
const startFlag = await this.isGameStart(); // 直接显示排行榜
if (startFlag) { this.runRankList();
// 直接显示排行榜 await this.loadData();
cc.find(`Canvas/rankpage`).active = true; this.drawPage();
this.runRankList();
} else {
await this.loadData();
this.drawPage();
}
} }
async runRankList() { async runRankList() {
let rows = await asyncCallNetworkApiGet('/api/douyin/v1/rank', {roomid: this.roomId}); const startFlag = await this.isGameStart();
// let rows = await asyncCallNetworkApiGet('/api/douyin/v1/rank', {roomid: "7248252618835790603"}); if (startFlag) {
rows = JSON.parse(rows); this.rankpage.active = true;
this.rankContent.removeAllChildren(); let rows = await asyncCallNetworkApiGet('/api/douyin/v1/rank', {roomid: this.roomId});
for (let i = 0; i < rows.length; i++) { // let rows = await asyncCallNetworkApiGet('/api/douyin/v1/rank', {roomid: "7248252618835790603"});
const row = rows[i]; rows = JSON.parse(rows);
const itemClone = cc.instantiate(this.rankTemplate); this.rankContent.removeAllChildren();
itemClone.parent = this.rankContent; for (let i = 0; i < rows.length; i++) {
itemClone.active = true; const row = rows[i];
itemClone.attr({user_id: row.user_id}); const itemClone = cc.instantiate(this.rankTemplate);
cc.find(`ready`,itemClone).active = false; itemClone.parent = this.rankContent;
cc.find(`score`,itemClone).active = true; itemClone.active = true;
cc.find(`score`,itemClone).getComponent(cc.Label).string = row.score; itemClone.attr({user_id: row.user_id});
const nickObj = JSON.parse(row.nick_name); cc.find(`ready`,itemClone).active = false;
await this.drawNickName(itemClone, nickObj); cc.find(`score`,itemClone).active = true;
cc.find(`score`,itemClone).getComponent(cc.Label).string = row.score;
const nickObj = JSON.parse(row.nick_name);
await this.drawNickName(itemClone, nickObj);
}
} else {
this.rankpage.active = false;
} }
this.scheduleOnce( async () => { this.scheduleOnce( async () => {
const startFlag = await this.isGameStart(); await this.runRankList();
if (startFlag) {
await this.runRankList();
}
}, 1); }, 1);
} }
...@@ -251,10 +253,35 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -251,10 +253,35 @@ export default class SceneComponent extends MyCocosSceneComponent {
roomid: this.roomId, roomid: this.roomId,
data: keys.join(","), data: keys.join(","),
}); });
this.rankpage.active = true;
this.canTouch = true;
}
// 显示排行榜 async restart() {
cc.find(`Canvas/rankpage`).active = true; if (!this.canTouch) {
this.runRankList(); return;
}
this.canTouch = false;
cc.find(`Canvas/loading`).active = true;
await asyncCallNetworkApiGet("/api/douyin/v1/stopgame", {
roomid: this.roomId
});
await asyncDelay(5);
await asyncCallNetworkApiGet("/api/douyin/v1/startgame", {
roomid: this.roomId
});
cc.find(`Canvas/loading`).active = false;
this.canTouch = true;
}
async reset() {
if (!this.canTouch) {
return;
}
this.canTouch = false;
await asyncCallNetworkApiGet("/api/douyin/v1/stopgame", {
roomid: this.roomId
});
this.rankpage.active = false;
this.canTouch = true; this.canTouch = true;
} }
......
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