
每个桌子的 点击事件。

import global from "./global";
cc.Class({
extends: cc.Component,
properties: {
name_ : cc.Label,
},
// onLoad () {},
start () {
},
init(tableData){
this.name_.string = tableData.name;
this.roomId = tableData.id;
},
btnClick(event, data) {
if (data == "join_room") {
console.log("join_room:id"+this.roomId);
let data={};
data.roomId=this.roomId
global.eventlistener.fire("join_room",JSON.stringify(data));
}
}
// update (dt) {},
});
global.eventlistener.on("join_room", function (data) {
console.log("加入房间的数据:" + data);
//请求这个房间所有的人
data = JSON.parse(data);
let roomId = data.roomId;
global.roomId = roomId;
let data2 = {};
data2.roomId = roomId;
data2.clientId = global.client.id;
console.log(JSON.stringify(data2));
window.HttpHelper.httpPost(global.website + "/api/cocos/get/room/paler/list", JSON.stringify(data2), function (rsp) {
//post 这里会输出3次 -1 不知道 啥情况
if (rsp != -1) {
console.log(rsp);
if (rsp.success) {
//房间里面所有的人,包括我自己
global.playerList = rsp.roomClientList;
//我所在的位置index_有可能是3位 或者 4位。
global.client.index_ = rsp.index_;
console.log("房主id:" + global.playerList[0].client.id)
global.house_manage_id = global.playerList[0].client.id;
//初始化我的game_world场景
let game_world = cc.instantiate(self.game_world);
game_world.parent = self.node;
self.table_layer.active = false;
} else {
console.log(rsp.msg);
}
}
});
//进入房间后 销毁,掉选择房间的界面
// self.table_layer.removeFromParent(true);
// self.table_layer.destroy();
//进入房间后 销毁,掉选择房间的界面
});站长微信:xiaomao0055
站长QQ:14496453