Commit 857b0688 authored by 范雪寒's avatar 范雪寒

feat: 素材

parent 2c39b90e
{"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 "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
import { RandomInt } from "../script/util"; import { Base64 } from "js-base64";
export class NetworkHelper { export class NetworkHelper {
...@@ -10,9 +10,16 @@ export class NetworkHelper { ...@@ -10,9 +10,16 @@ export class NetworkHelper {
} }
async init(roomType: string, maxPlayers: number) { async init(roomType: string, maxPlayers: number) {
await this.initRoom(); this.initRoom();
try {
return await this.joinRoom(roomType, maxPlayers);
} catch (e) {
await this.initListener();
this.initRoom();
return await this.joinRoom(roomType, maxPlayers); return await this.joinRoom(roomType, maxPlayers);
} }
}
async startGame() { async startGame() {
await this.startFrameSync(); await this.startFrameSync();
...@@ -28,18 +35,28 @@ export class NetworkHelper { ...@@ -28,18 +35,28 @@ export class NetworkHelper {
return this.room.roomInfo; return this.room.roomInfo;
} }
room: MGOBE.Room; initListener() {
initRoom(cacertFile: any = undefined) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const gameId = "obg-i4ql53h1"; //替换为控制台上的 游戏 ID const gameId = "obg-i4ql53h1"; //替换为控制台上的 游戏 ID
const secretKey = "060d81c7abaf24c8ce2afc5a725c152062676d35"; //替换为控制台上的 游戏 Key const openId = "openid_op_16" + Math.random();
const serverUrl = "i4ql53h1.wxlagame.com"; //替换为控制台上的 域名
const gameInfo = { const gameInfo: MGOBE.types.GameInfoPara = {
gameId: gameId, gameId: gameId,
openId: "openid_test" + Math.random(), //自定义的用户唯一ID openId: openId,
secretKey: secretKey secretKey: "060d81c7abaf24c8ce2afc5a725c152062676d35",
// createSignature: (callback) => {
// this.callNetworkApiGet('http://192.168.3.142:8081', '/getSign', {
// gameId: gameId,
// openId: openId,
// }, (data) => {
// const signature = JSON.parse(data);
// console.log(JSON.stringify(signature));
// callback(signature);
// });
// }
}; };
const serverUrl = "i4ql53h1.wxlagame.com"; //替换为控制台上的 域名
const config = { const config = {
url: serverUrl, url: serverUrl,
reconnectMaxTimes: 5, reconnectMaxTimes: 5,
...@@ -49,26 +66,39 @@ export class NetworkHelper { ...@@ -49,26 +66,39 @@ export class NetworkHelper {
cacertNativeUrl: "" cacertNativeUrl: ""
}; };
MGOBE.DebuggerLog.enable = true; MGOBE.DebuggerLog.enable = false;
// 如果是原生平台,则加载 Cert 证书,否则会提示 WSS 错误 // 如果是原生平台,则加载 Cert 证书,否则会提示 WSS 错误
if (cc.sys.isNative) { if (cc.sys.isNative) {
let cacertFile;
const cacertNode = cc.find('cacertNode');
if (cacertNode) {
cacertFile = cacertNode.getComponent('cacert').cacertFile;
}
if (!cacertFile) { if (!cacertFile) {
this.log('没有cacertFile!!!'); this.log('没有cacertFile!!!');
} }
this.log('汪汪汪: ' + cacertFile.nativeUrl);
config.cacertNativeUrl = cc.loader.md5Pipe && cc.ENGINE_VERSION < "2.4.0" ? config.cacertNativeUrl = cc.loader.md5Pipe && cc.ENGINE_VERSION < "2.4.0" ?
cc.loader.md5Pipe.transformURL(cacertFile.nativeUrl) : cc.loader.md5Pipe.transformURL(cacertFile.nativeUrl) :
cacertFile.nativeUrl; cacertFile.nativeUrl;
} }
MGOBE.Listener.init(gameInfo, config, event => { MGOBE.Listener.init(gameInfo, config, event => {
console.log(event); this.log(JSON.stringify(event));
if (event.code !== 0) { if (event.code !== 0) {
this.log("初始化失败: " + event.code); this.log("初始化失败: " + event.code);
reject(); reject();
return; return;
} }
this.log("初始化成功"); this.log("初始化成功");
resolve(null);
});
});
}
room: MGOBE.Room;
initRoom() {
this.room = new MGOBE.Room(); this.room = new MGOBE.Room();
MGOBE.Listener.add(this.room); MGOBE.Listener.add(this.room);
this.room.onJoinRoom = this.onJoinRoom.bind(this); this.room.onJoinRoom = this.onJoinRoom.bind(this);
...@@ -78,9 +108,7 @@ export class NetworkHelper { ...@@ -78,9 +108,7 @@ export class NetworkHelper {
this.room.onStartFrameSync = this.onStartFrameSync.bind(this); this.room.onStartFrameSync = this.onStartFrameSync.bind(this);
this.room.onStopFrameSync = this.onStopFrameSync.bind(this); this.room.onStopFrameSync = this.onStopFrameSync.bind(this);
this.room.onRecvFromGameSvr = this.onRecvFromGameSvr.bind(this); this.room.onRecvFromGameSvr = this.onRecvFromGameSvr.bind(this);
resolve(null); this.log('this.room = ' + JSON.stringify(this.room.roomInfo));
});
});
} }
joinRoom(roomType: string, maxPlayers: number, customData: string = '') { joinRoom(roomType: string, maxPlayers: number, customData: string = '') {
...@@ -99,14 +127,14 @@ export class NetworkHelper { ...@@ -99,14 +127,14 @@ export class NetworkHelper {
}; };
this.room.matchRoom(matchRoomPara, event => { this.room.matchRoom(matchRoomPara, event => {
console.log(event); this.log(JSON.stringify(event))
if (event.code === 0) { if (event.code === 0) {
cc.log("匹配成功"); cc.log("匹配成功: " + event.data.roomInfo.id);
const player = event.data.roomInfo.playerList.find(player => player.name == playerName); const player = event.data.roomInfo.playerList.find(player => player.name == playerName);
resolve(player.id); resolve(player.id);
} else { } else {
cc.log("匹配失败"); cc.log("匹配失败");
reject(); reject(event);
} }
}); });
}); });
...@@ -115,11 +143,13 @@ export class NetworkHelper { ...@@ -115,11 +143,13 @@ export class NetworkHelper {
leaveRoom() { leaveRoom() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.room.leaveRoom({}, event => { this.room.leaveRoom({}, event => {
console.log(event); this.log(JSON.stringify(event))
if (event.code === 0) { if (event.code === 0) {
cc.log("退房成功", this.room.roomInfo.id); this.log("退房成功" + this.room.roomInfo.id);
this.room.initRoom(); // this.room.initRoom();
resolve(null); resolve(null);
} else {
this.log("退房失败");
} }
}); });
}); });
...@@ -127,9 +157,9 @@ export class NetworkHelper { ...@@ -127,9 +157,9 @@ export class NetworkHelper {
closeRoom() { closeRoom() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.room.changeRoom({ isForbidJoin: false }, (event) => { this.room.changeRoom({ isForbidJoin: true }, (event) => {
console.log('关门') console.log('关门')
console.log(event); this.log(JSON.stringify(event))
resolve(null); resolve(null);
}); });
}); });
...@@ -147,7 +177,7 @@ export class NetworkHelper { ...@@ -147,7 +177,7 @@ export class NetworkHelper {
startFrameSync() { startFrameSync() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.room.startFrameSync({}, event => { this.room.startFrameSync({}, event => {
console.log(event); this.log(JSON.stringify(event))
if (event.code === 0) { if (event.code === 0) {
cc.log("开始帧同步成功,请到控制台查看具体帧同步信息"); cc.log("开始帧同步成功,请到控制台查看具体帧同步信息");
resolve(null); resolve(null);
...@@ -160,12 +190,17 @@ export class NetworkHelper { ...@@ -160,12 +190,17 @@ export class NetworkHelper {
stopFrameSync() { stopFrameSync() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!this.room) {
resolve(null);
return;
}
this.room.stopFrameSync({}, event => { this.room.stopFrameSync({}, event => {
console.log(event); this.log(JSON.stringify(event))
if (event.code === 0) { if (event.code === 0) {
cc.log("停止帧同步成功"); this.log("停止帧同步成功");
resolve(null); resolve(null);
} else { } else {
this.log("停止帧同步失败");
reject(event.code); reject(event.code);
} }
}); });
...@@ -216,6 +251,17 @@ export class NetworkHelper { ...@@ -216,6 +251,17 @@ export class NetworkHelper {
onStopFrameSync(event) { } onStopFrameSync(event) { }
onRecvFromGameSvr() { } onRecvFromGameSvr() { }
async onDestroy() {
try {
this.log('onDestroy1')
MGOBE.Listener.clear();
await this.stopGame();
this.log('onDestroy2')
} catch (e) {
this.log(JSON.stringify(e));
}
}
log(str) { log(str) {
const node = cc.find('middleLayer'); const node = cc.find('middleLayer');
if (node) { if (node) {
...@@ -224,4 +270,25 @@ export class NetworkHelper { ...@@ -224,4 +270,25 @@ export class NetworkHelper {
cc.log(str); cc.log(str);
} }
} }
callNetworkApiGet(baseUrl, uri, data, callBack) {
let queryStr = '?';
const params = [];
for (const key in data) {
if (Object.hasOwnProperty.call(data, key)) {
params.push(`${key}=${data[key]}`);
}
}
queryStr += params.join("&");
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
callBack(xhr.responseText);
}
};
const url = `${baseUrl}${uri}${queryStr}`;
console.log('url = ' + url);
xhr.open('GET', url, true);
xhr.send();
}
} }
\ No newline at end of file
This diff is collapsed.
...@@ -33,25 +33,20 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -33,25 +33,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
async initData() { async initData() {
this.networkHelper = new NetworkHelper(); this.networkHelper = new NetworkHelper();
let cacertFile; // this.networkHelper.initListener();
const cacertNode = cc.find('cacertNode'); await this.networkHelper.initRoom();
if (cacertNode) {
cacertFile = cacertNode.getComponent('cacert').cacertFile;
}
await this.networkHelper.initRoom(cacertFile);
this.playerId = await this.networkHelper.joinRoom('op_16', 2); this.playerId = await this.networkHelper.joinRoom('op_16', 2);
// const roomInfo = this.networkHelper.getRoomInfo(); const roomInfo = this.networkHelper.getRoomInfo();
// if (roomInfo.playerList.length == roomInfo.maxPlayers) { if (roomInfo.playerList.length == roomInfo.maxPlayers) {
// if (this.playerId == roomInfo.playerList[0].id) { if (this.playerId == roomInfo.playerList[0].id) {
// this.networkHelper.startGame(); this.networkHelper.startGame();
// } }
// } }
// roomInfo.playerList.forEach(player => { roomInfo.playerList.forEach(player => {
// // const startPos = JSON.parse(player.customProfile); // const startPos = JSON.parse(player.customProfile);
// // this.createTank(player.id, startPos); // this.createTank(player.id, startPos);
// }); });
this.networkHelper.on('playerJoin', (event) => { this.networkHelper.on('playerJoin', (event) => {
const roomInfo = this.networkHelper.getRoomInfo(); const roomInfo = this.networkHelper.getRoomInfo();
......
{
"ver": "1.1.2",
"uuid": "70674558-1a2c-4db0-a8b3-e82ee8ec6700",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "dc66cdd6-146b-48d7-9d91-a66bfff63a0c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 247,
"height": 90,
"platformSettings": {},
"subMetas": {
"alligator": {
"ver": "1.0.4",
"uuid": "9b768bf7-cf8c-49b3-84e8-8c9b0e6e4107",
"rawTextureUuid": "dc66cdd6-146b-48d7-9d91-a66bfff63a0c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 247,
"height": 90,
"rawWidth": 247,
"rawHeight": 90,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "3b76113d-2fc0-4e0d-b465-16f64d80421f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 149,
"height": 122,
"platformSettings": {},
"subMetas": {
"ant": {
"ver": "1.0.4",
"uuid": "73c87047-363f-46ed-81f3-3dd65bbad6e5",
"rawTextureUuid": "3b76113d-2fc0-4e0d-b465-16f64d80421f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 149,
"height": 122,
"rawWidth": 149,
"rawHeight": 122,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "27fcce91-8d26-48c5-9caa-ffea5c24f2b7",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 147,
"height": 154,
"platformSettings": {},
"subMetas": {
"apple": {
"ver": "1.0.4",
"uuid": "8c38b8f0-a7a6-4616-958c-8caa0f86b6aa",
"rawTextureUuid": "27fcce91-8d26-48c5-9caa-ffea5c24f2b7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 147,
"height": 154,
"rawWidth": 147,
"rawHeight": 154,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5b742e97-a911-47c9-a28c-01cb82242e82",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 186,
"height": 203,
"platformSettings": {},
"subMetas": {
"ax": {
"ver": "1.0.4",
"uuid": "6c00e05c-fe9b-459c-841c-432bdd8a4730",
"rawTextureUuid": "5b742e97-a911-47c9-a28c-01cb82242e82",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 186,
"height": 203,
"rawWidth": 186,
"rawHeight": 203,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e5be515e-680f-4bcd-bcb9-c35974e55ba7",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 212,
"height": 182,
"platformSettings": {},
"subMetas": {
"banana": {
"ver": "1.0.4",
"uuid": "de55a263-2fbb-4727-a63b-44c757529c87",
"rawTextureUuid": "e5be515e-680f-4bcd-bcb9-c35974e55ba7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 212,
"height": 182,
"rawWidth": 212,
"rawHeight": 182,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5657c02b-f554-424f-9f3f-3ab424f374f3",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 201,
"height": 158,
"platformSettings": {},
"subMetas": {
"bear": {
"ver": "1.0.4",
"uuid": "10b8b2ab-5c5c-4b4d-9f0a-f61ec3324468",
"rawTextureUuid": "5657c02b-f554-424f-9f3f-3ab424f374f3",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 201,
"height": 158,
"rawWidth": 201,
"rawHeight": 158,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2dd6da46-0f4f-4378-9526-3786d7090859",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 209,
"height": 165,
"platformSettings": {},
"subMetas": {
"bed": {
"ver": "1.0.4",
"uuid": "244e49a4-bd83-4f7d-9eb3-48bf20c9c807",
"rawTextureUuid": "2dd6da46-0f4f-4378-9526-3786d7090859",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 209,
"height": 165,
"rawWidth": 209,
"rawHeight": 165,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b436e1b7-b679-4e73-a974-1a9bf81d1f4c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 172,
"height": 143,
"platformSettings": {},
"subMetas": {
"bird": {
"ver": "1.0.4",
"uuid": "863ade14-4677-42c7-b655-4f8b9d31e0bb",
"rawTextureUuid": "b436e1b7-b679-4e73-a974-1a9bf81d1f4c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 172,
"height": 143,
"rawWidth": 172,
"rawHeight": 143,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "06d481a5-af91-4dfb-840e-4a5e33fd6401",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 209,
"height": 114,
"platformSettings": {},
"subMetas": {
"car": {
"ver": "1.0.4",
"uuid": "04ad048f-11bf-48fb-ace5-035a41fa636d",
"rawTextureUuid": "06d481a5-af91-4dfb-840e-4a5e33fd6401",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 209,
"height": 114,
"rawWidth": 209,
"rawHeight": 114,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ead5df19-44eb-42ae-8255-b3d4c6b8d952",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 176,
"height": 147,
"platformSettings": {},
"subMetas": {
"cat": {
"ver": "1.0.4",
"uuid": "df29829b-8e4e-43d8-96b3-173795a1f8ac",
"rawTextureUuid": "ead5df19-44eb-42ae-8255-b3d4c6b8d952",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 176,
"height": 147,
"rawWidth": 176,
"rawHeight": 147,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e4c6a637-96ed-4df7-8a53-ec479306fdc7",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 199,
"height": 192,
"platformSettings": {},
"subMetas": {
"computer": {
"ver": "1.0.4",
"uuid": "cb81a696-9714-4858-b79e-3fedea357230",
"rawTextureUuid": "e4c6a637-96ed-4df7-8a53-ec479306fdc7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 199,
"height": 192,
"rawWidth": 199,
"rawHeight": 192,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "bfe0c4b0-3ba6-4a88-b506-694ede89ca43",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 171,
"height": 167,
"platformSettings": {},
"subMetas": {
"desk": {
"ver": "1.0.4",
"uuid": "1e8cfdb2-9bfb-4615-8f8e-ffcdf0213144",
"rawTextureUuid": "bfe0c4b0-3ba6-4a88-b506-694ede89ca43",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 171,
"height": 167,
"rawWidth": 171,
"rawHeight": 167,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "91d6e35c-f421-4c4a-a3d8-8704aba05430",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 218,
"height": 168,
"platformSettings": {},
"subMetas": {
"dog": {
"ver": "1.0.4",
"uuid": "919b3949-a2fa-46a6-8989-f205872e46e7",
"rawTextureUuid": "91d6e35c-f421-4c4a-a3d8-8704aba05430",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 218,
"height": 168,
"rawWidth": 218,
"rawHeight": 168,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "50daa155-ab70-41ae-a5b5-6c22e46c8759",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 119,
"height": 187,
"platformSettings": {},
"subMetas": {
"doll": {
"ver": "1.0.4",
"uuid": "d82d56e1-2b92-4a67-b40e-4832c96f458f",
"rawTextureUuid": "50daa155-ab70-41ae-a5b5-6c22e46c8759",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 119,
"height": 187,
"rawWidth": 119,
"rawHeight": 187,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0aa7aaf9-5672-4d0a-b2d3-f1eca0906813",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 141,
"height": 109,
"platformSettings": {},
"subMetas": {
"duck": {
"ver": "1.0.4",
"uuid": "bcb70583-09ee-428d-bb91-222549163078",
"rawTextureUuid": "0aa7aaf9-5672-4d0a-b2d3-f1eca0906813",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 141,
"height": 109,
"rawWidth": 141,
"rawHeight": 109,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "d758e0da-c30b-4a1f-9033-b43b0ac3930c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 112,
"height": 149,
"platformSettings": {},
"subMetas": {
"egg": {
"ver": "1.0.4",
"uuid": "acc278f9-b5f4-4288-93d1-5a30e5dc35cf",
"rawTextureUuid": "d758e0da-c30b-4a1f-9033-b43b0ac3930c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 112,
"height": 149,
"rawWidth": 112,
"rawHeight": 149,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f9d8b802-3550-45d7-bf86-6ad564f29a7c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 181,
"height": 170,
"platformSettings": {},
"subMetas": {
"elbow": {
"ver": "1.0.4",
"uuid": "5586910f-fe59-492e-a3ed-62fa855790a6",
"rawTextureUuid": "f9d8b802-3550-45d7-bf86-6ad564f29a7c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 181,
"height": 170,
"rawWidth": 181,
"rawHeight": 170,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2344743f-7fe7-4f00-9d31-28feeec1c193",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 210,
"height": 169,
"platformSettings": {},
"subMetas": {
"elephant": {
"ver": "1.0.4",
"uuid": "810735cf-f63e-4e2b-b796-09b09026e6d8",
"rawTextureUuid": "2344743f-7fe7-4f00-9d31-28feeec1c193",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 210,
"height": 169,
"rawWidth": 210,
"rawHeight": 169,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "27b946d3-ffad-4328-b504-ca2c9694cc3a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 167,
"height": 133,
"platformSettings": {},
"subMetas": {
"envelope": {
"ver": "1.0.4",
"uuid": "e15c3a2f-84f8-452f-9351-b02ec37ea3fb",
"rawTextureUuid": "27b946d3-ffad-4328-b504-ca2c9694cc3a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 167,
"height": 133,
"rawWidth": 167,
"rawHeight": 133,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "3e472bd4-1f99-4a5c-8f00-519aee62f58b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 177,
"height": 131,
"platformSettings": {},
"subMetas": {
"fan": {
"ver": "1.0.4",
"uuid": "418b3bae-b458-476b-88af-e89b59693eaa",
"rawTextureUuid": "3e472bd4-1f99-4a5c-8f00-519aee62f58b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 177,
"height": 131,
"rawWidth": 177,
"rawHeight": 131,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "fdea02e6-4c62-455d-bc32-302a511a547f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 233,
"height": 121,
"platformSettings": {},
"subMetas": {
"fish": {
"ver": "1.0.4",
"uuid": "57e07c08-0810-4191-8151-15815c4ebb7b",
"rawTextureUuid": "fdea02e6-4c62-455d-bc32-302a511a547f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 233,
"height": 121,
"rawWidth": 233,
"rawHeight": 121,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "967b8387-0dea-40b2-9264-60ada34fb97a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 184,
"height": 145,
"platformSettings": {},
"subMetas": {
"fork": {
"ver": "1.0.4",
"uuid": "8309d0f6-4d8d-4e3b-ab75-e4ac8a8bd3df",
"rawTextureUuid": "967b8387-0dea-40b2-9264-60ada34fb97a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 184,
"height": 145,
"rawWidth": 184,
"rawHeight": 145,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ad7f7552-623d-499f-8997-eedbb742a901",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 184,
"height": 87,
"platformSettings": {},
"subMetas": {
"tea": {
"ver": "1.0.4",
"uuid": "5ab25ead-3f4f-4b09-8c38-113693114a09",
"rawTextureUuid": "ad7f7552-623d-499f-8997-eedbb742a901",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 184,
"height": 87,
"rawWidth": 184,
"rawHeight": 87,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "0d16e2b9-fdd6-4d66-bca3-c74d7eab2134",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ba7cfff6-9d3b-4c17-8cfe-0f253578f734",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 95,
"height": 95,
"platformSettings": {},
"subMetas": {
"prograssbar_light": {
"ver": "1.0.4",
"uuid": "003d9202-6c8b-4161-9866-fd33e95c843c",
"rawTextureUuid": "ba7cfff6-9d3b-4c17-8cfe-0f253578f734",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 95,
"height": 95,
"rawWidth": 95,
"rawHeight": 95,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "07946b28-6576-47cc-a570-9de70791159a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 174,
"height": 169,
"platformSettings": {},
"subMetas": {
"star_01": {
"ver": "1.0.4",
"uuid": "1f2bd6e5-dfe4-4b37-a62b-c9031bc01d99",
"rawTextureUuid": "07946b28-6576-47cc-a570-9de70791159a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 174,
"height": 169,
"rawWidth": 174,
"rawHeight": 169,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
const express = require('express'); const express = require('express');
const os = require('os'); const os = require('os');
const readline = require('readline'); const readline = require('readline');
const Base64 = require('js-base64');
const CryptoJS = require("crypto-js");
const { build, buildAndroid, buildIos } = require('./buildCocos'); const { build, buildAndroid, buildIos } = require('./buildCocos');
const networkInfo = os.networkInterfaces(); const networkInfo = os.networkInterfaces();
...@@ -18,11 +20,31 @@ for (const infos of Object.values(networkInfo)) { ...@@ -18,11 +20,31 @@ for (const infos of Object.values(networkInfo)) {
var app = express(); var app = express();
// Access-Control-Allow-Origin: *
app.use('/dist', express.static('dist')); app.use('/dist', express.static('dist'));
app.get('/', function (req, res) { app.get('/', function (req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.send('Hello World'); 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 }));
});
let port = ''; let port = '';
var server = app.listen(8081, function () { var server = app.listen(8081, function () {
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@types/crypto-js": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.0.2.tgz",
"integrity": "sha512-sCVniU+h3GcGqxOmng11BRvf9TfN9yIs8KKjB8C8d75W69cpTfZG80gau9yTx5SxF3gvHGbJhdESzzvnjtf3Og=="
},
"accepts": { "accepts": {
"version": "1.3.7", "version": "1.3.7",
"resolved": "https://registry.npm.taobao.org/accepts/download/accepts-1.3.7.tgz", "resolved": "https://registry.npm.taobao.org/accepts/download/accepts-1.3.7.tgz",
...@@ -144,6 +149,16 @@ ...@@ -144,6 +149,16 @@
"resolved": "https://registry.nlark.com/core-util-is/download/core-util-is-1.0.3.tgz", "resolved": "https://registry.nlark.com/core-util-is/download/core-util-is-1.0.3.tgz",
"integrity": "sha1-pgQtNjTCsn6TKPg3uWX6yDgI24U=" "integrity": "sha1-pgQtNjTCsn6TKPg3uWX6yDgI24U="
}, },
"crypto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig=="
},
"crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"debug": { "debug": {
"version": "2.6.9", "version": "2.6.9",
"resolved": "https://registry.npmmirror.com/debug/download/debug-2.6.9.tgz", "resolved": "https://registry.npmmirror.com/debug/download/debug-2.6.9.tgz",
......
...@@ -11,11 +11,14 @@ ...@@ -11,11 +11,14 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@types/crypto-js": "^4.0.2",
"base-64": "^1.0.0", "base-64": "^1.0.0",
"child_process": "^1.0.2",
"compressing": "^1.5.1", "compressing": "^1.5.1",
"crypto": "^1.0.1",
"crypto-js": "^4.1.1",
"express": "^4.17.1",
"js-base64": "^3.7.2", "js-base64": "^3.7.2",
"uuid": "^8.3.2", "uuid": "^8.3.2"
"child_process": "^1.0.2",
"express": "^4.17.1"
} }
} }
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