diff --git a/assets/resources/prefab.meta b/assets/resources/prefab.meta index 029faba..de13b1c 100644 --- a/assets/resources/prefab.meta +++ b/assets/resources/prefab.meta @@ -2,11 +2,19 @@ "ver": "1.1.2", "uuid": "51ab963a-0f0f-405d-b2ed-de80bcf1b09d", "isBundle": false, - "bundleName": "", + "bundleName": "resPrefabSub", "priority": 1, - "compressionType": {}, - "optimizeHotUpdate": {}, - "inlineSpriteFrames": {}, - "isRemoteBundle": {}, + "compressionType": { + "wechatgame": "subpackage" + }, + "optimizeHotUpdate": { + "wechatgame": false + }, + "inlineSpriteFrames": { + "wechatgame": false + }, + "isRemoteBundle": { + "wechatgame": false + }, "subMetas": {} } \ No newline at end of file diff --git a/assets/resources/prefab/GroupLoading.prefab b/assets/resources/prefab/GroupLoading.prefab index c066532..c9ca312 100644 --- a/assets/resources/prefab/GroupLoading.prefab +++ b/assets/resources/prefab/GroupLoading.prefab @@ -55,8 +55,8 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 0, - 0, + 480, + 320, 0, 0, 0, @@ -333,7 +333,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "cfwwBg4kBJtIPsmKjs15qx", "sync": false @@ -440,7 +440,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "cbqvbq8KNLLYhaFR3uBhkv", "sync": false @@ -547,7 +547,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "1bMPTqadlLS58gYe12LwTu", "sync": false @@ -654,7 +654,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "0c9L15l51ESKKpTPfrad3P", "sync": false @@ -769,7 +769,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "22L//z2sxKS5DZVVw13+jZ", "sync": false @@ -807,7 +807,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "01J4EninBHMIvhUvWtvKdx", "sync": false @@ -877,7 +877,7 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, "fileId": "dbZ3uMYvpCWZ7RgwxByahh", "sync": false @@ -942,9 +942,9 @@ "__id__": 1 }, "asset": { - "__id__": 0 + "__uuid__": "71636309-0613-4d9c-8f24-8e67532b7145" }, - "fileId": "7ct/TyDrFBvJ3UNUeRltSm", + "fileId": "", "sync": false } ] \ No newline at end of file diff --git a/assets/resources/prefab/subpack/keyboard.prefab b/assets/resources/prefab/keyboard.prefab similarity index 100% rename from assets/resources/prefab/subpack/keyboard.prefab rename to assets/resources/prefab/keyboard.prefab diff --git a/assets/resources/prefab/subpack/keyboard.prefab.meta b/assets/resources/prefab/keyboard.prefab.meta similarity index 100% rename from assets/resources/prefab/subpack/keyboard.prefab.meta rename to assets/resources/prefab/keyboard.prefab.meta diff --git a/assets/resources/prefab/subpack/script/keyboard.ts b/assets/resources/prefab/script/keyboard.ts similarity index 100% rename from assets/resources/prefab/subpack/script/keyboard.ts rename to assets/resources/prefab/script/keyboard.ts diff --git a/assets/resources/prefab/subpack/script/keyboard.ts.meta b/assets/resources/prefab/script/keyboard.ts.meta similarity index 100% rename from assets/resources/prefab/subpack/script/keyboard.ts.meta rename to assets/resources/prefab/script/keyboard.ts.meta diff --git a/assets/resources/prefab/subpack/script/stopGames.ts b/assets/resources/prefab/script/stopGames.ts similarity index 89% rename from assets/resources/prefab/subpack/script/stopGames.ts rename to assets/resources/prefab/script/stopGames.ts index b020303..601a47c 100644 --- a/assets/resources/prefab/subpack/script/stopGames.ts +++ b/assets/resources/prefab/script/stopGames.ts @@ -5,8 +5,9 @@ // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +import { shareAppMessage } from "../utils/prefabTool"; + const {ccclass} = cc._decorator; -import { shareAppMessage } from '../../../../scripts/lib/tool'; @ccclass export default class StopGames extends cc.Component { diff --git a/assets/resources/prefab/subpack/script/stopGames.ts.meta b/assets/resources/prefab/script/stopGames.ts.meta similarity index 100% rename from assets/resources/prefab/subpack/script/stopGames.ts.meta rename to assets/resources/prefab/script/stopGames.ts.meta diff --git a/assets/resources/prefab/subpack/stopGames.prefab b/assets/resources/prefab/stopGames.prefab similarity index 100% rename from assets/resources/prefab/subpack/stopGames.prefab rename to assets/resources/prefab/stopGames.prefab diff --git a/assets/resources/prefab/subpack/stopGames.prefab.meta b/assets/resources/prefab/stopGames.prefab.meta similarity index 100% rename from assets/resources/prefab/subpack/stopGames.prefab.meta rename to assets/resources/prefab/stopGames.prefab.meta diff --git a/assets/resources/prefab/subpack.meta b/assets/resources/prefab/subpack.meta deleted file mode 100644 index e2d2f26..0000000 --- a/assets/resources/prefab/subpack.meta +++ /dev/null @@ -1,20 +0,0 @@ -{ - "ver": "1.1.2", - "uuid": "4f9f4fa2-1e1d-44ef-974d-be13e74f7257", - "isBundle": true, - "bundleName": "resPrefabSub", - "priority": 5, - "compressionType": { - "wechatgame": "subpackage", - "baidugame": "subpackage", - "xiaomi": "subpackage", - "quickgame": "subpackage", - "qgame": "subpackage", - "huawei": "subpackage", - "cocos-runtime": "subpackage" - }, - "optimizeHotUpdate": {}, - "inlineSpriteFrames": {}, - "isRemoteBundle": {}, - "subMetas": {} -} \ No newline at end of file diff --git a/assets/resources/prefab/subpack/script.meta b/assets/resources/prefab/utils.meta similarity index 80% rename from assets/resources/prefab/subpack/script.meta rename to assets/resources/prefab/utils.meta index 6641a43..0c24dd4 100644 --- a/assets/resources/prefab/subpack/script.meta +++ b/assets/resources/prefab/utils.meta @@ -1,6 +1,6 @@ { "ver": "1.1.2", - "uuid": "19010ff6-300b-46e0-aa00-c6c7c1be0ccb", + "uuid": "fc2cb3c4-a55f-49e1-b824-6a84208e72d4", "isBundle": false, "bundleName": "", "priority": 1, diff --git a/assets/resources/prefab/utils/prefabTool.ts b/assets/resources/prefab/utils/prefabTool.ts new file mode 100644 index 0000000..34fbeb4 --- /dev/null +++ b/assets/resources/prefab/utils/prefabTool.ts @@ -0,0 +1,250 @@ + +/** + * 格式化日期 + * @param fmt 日期格式 如:yyyy-MM-dd HH:mm:ss + * @param form 指定时间 不传参 默认目前时间 + */ +export function dateFrom(fmt: string = 'yyyy-MM-dd HH:mm:ss', form?: number) { + const date: any = form ? new Date(form) : new Date(); + const o: any = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, + 'H+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds(), + 'q+': Math.floor((date.getMonth() + 3) / 3), + 'S': date.getMilliseconds(), + }; + const week: string[] = [ '日', '一', '二', '三', '四', '五', '六' ]; + const season: string[] = [ '', '春', '夏', '秋', '冬' ]; + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); + } + if (/(E+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '星期' : '周') : '') + + week[date.getDay()]); + } + if (/(q+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, season[o['q+']] + ((RegExp.$1.length > 1) ? '季' : '')); + } + let k: string; + for (k in o) { + if (new RegExp('(' + k + ')').test(fmt)) { + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))); + } + } + return fmt; +} + + +/** + * 分享转发 + * @param title 转发标题,不传则默认使用当前小游戏的昵称 + * @param imageUrl 转发显示图片的链接,可以是网络图片路径或本地图片文件路径或相对代码包根目录的图片文件路径。显示图片长宽比是 5:4 + * @param query 查询字符串,从这条转发消息进入后,可通过 wx.getLaunchOptionsSync() 或 wx.onShow() 获取启动参数中的 query。必须是 key1=val1&key2=val2 的格式。 + */ +export const shareAppMessage = (title: string, imageUrl?: string, query?: string | object) => { + if (CC_WECHATGAME) { + wx.shareAppMessage({ + title, + imageUrl, + query, + }); + } +} + + +/** + * 上传文件 + * @param unit 文件单位 + */ +export const uploadFile = (ossOption, fileName, unit?: string) => { + return new Promise((reslove, reject) => { + console.log(ossOption); + if (CC_WECHATGAME) { + // 微信上传 + wx.chooseImage({ + success (res) { + const tempFilePaths = res.tempFilePaths + console.log(tempFilePaths); + const suffix = tempFilePaths[0].match(/\.\w+$/); + ossOption.key = ossOption.startsWith + fileName + suffix; + + if (!/^\.(png|jpg)/.test(suffix)) { + return reject('文件类型错误!'); + } + + if (res.tempFiles[0].size > 1024 * 500) { + return reject('文件不能大于500KB!'); + } + + Window.wx.uploadFile({ + url: ossOption.host, + filePath: tempFilePaths[0], + name: 'file', + formData: ossOption, + header: { + 'content-type': 'application/json', + }, + success_action_status: '200', + success: reslove, + fial: reject, + }); + }, + fial: reject, + }); + } else if (CC_PREVIEW) { + const fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.click(); + const formData = new FormData(); + Object.keys(ossOption).forEach(key => { + formData.append(key, ossOption[key]); + }); + + fileInput.onchange = (e) => { + // reslove(fileInput.files); + formData.append('file', fileInput.files[0]); + console.log(fileInput.files); + // axios.request('post', ossOption.host, { + // data: formData, + // }).then(res => { + // console.log(res); + // }) + + let xhr = cc.loader.getXMLHttpRequest(); + xhr.open('post', ossOption.host, true); + // xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;'); + xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"); + xhr.onreadystatechange = function () { + + }; + let dataStr = ''; + Object.keys(formData || {}).forEach(key => { + dataStr += key + '=' + encodeURIComponent(formData[key]) + '&'; + }) + console.log(dataStr); + xhr.send(formData); + } + } + }); +} + + +/** + * 设置资源是否被释放 + * @param Recursively UID + * @param Auto 是否自动释放 + */ +export const setAutoRecursively = (Recursively: string[], Auto: boolean = true) => { + Recursively.forEach(val => cc.loader.setAutoReleaseRecursively(val, Auto)); +} + + +/** + * 如果为刘海屏则进行适配 + * @param node 节点 + */ +export const screenFringe = (nodes: cc.Node[]) => { + const isFringe = hasScreenFringe(); + if (isFringe) { + nodes.forEach(node => { + node.getComponent(cc.Widget).left += 60; + }); + } +} + + +/** + * 监听小游戏回到前台的事件 + * @param callback 回调 + * @param that this指向 + */ +export const onShow = (callback, that = null) => { + if (CC_WECHATGAME) { + wx.onShow(callback.bind(that)); + } +}; + + +/** + * 监听小游戏回到前台的事件 + * @param callback 回调 + * @param that this指向 + */ +export const offShow = (callback, that = null) => { + if (CC_WECHATGAME) { + wx.offShow(callback.bind(that)); + } +}; + + +/** + * 监听小游戏回到前台的事件 + * @param callback 回调 + * @param that this指向 + */ +export const onHide = (callback, that = null) => { + if (CC_WECHATGAME) { + wx.onHide(callback.bind(that)); + } +}; + + +/** + * 监听小游戏回到前台的事件 + * @param callback 回调 + * @param that this指向 + */ +export const offHide = (callback, that = null) => { + if (CC_WECHATGAME) { + wx.offHide(callback.bind(that)); + } +}; + + +/** + * 判断是否为刘海 + */ +const fringeScreenModels = [ + 'iPhone X', 'iPhone x', 'vivo X21A', 'ASUS Zenfone 5', + 'Ulefone T2 Pro', 'Leagoo S9', 'HUAWEI P20', 'DooGee V', + 'OPPO R15', 'LG G7', 'SAMSUNG S9', 'COR-AL00', + 'vivo Y83A', 'LLD-AL20', 'vivo Z1', 'PACM00', 'PAAM00' +]; +export const hasScreenFringe = () => { + const systemInfo = CC_WECHATGAME ? wx.getSystemInfoSync() : { model: null }; + + if (systemInfo.model != null) { + for (let i in fringeScreenModels) { + if (systemInfo.model.indexOf(fringeScreenModels[i]) > -1) { + // 是已知机型里的刘海手机 + return true; + } + } + } + // 屏幕宽高比大于2,基本上90%的手机可以确定是刘海屏,就算个别手机不是也按刘海屏处理 + // 竖屏游戏判断: + // if (systemInfo.windowHeight >= 800 || systemInfo.windowHeight / systemInfo.windowWidth > 2) { + // return true; + // } + + // 横屏游戏判断: + // if (this.systemInfo.windowWidth >= 800 || this.systemInfo.windowWidth / this.systemInfo.windowHeight > 2) { + // return true; + // } + return false; +} + + +/** + * 检测旋转屏幕 + */ +export const testingRotate = () => { + const { width, height } = cc.view.getFrameSize(); + cc.view.setFrameSize(width, width < height ? height / 3 : height); + if (width < height) { + alert('请横屏游玩!'); + } +} \ No newline at end of file diff --git a/assets/scripts/utils/tool.ts.meta b/assets/resources/prefab/utils/prefabTool.ts.meta similarity index 74% rename from assets/scripts/utils/tool.ts.meta rename to assets/resources/prefab/utils/prefabTool.ts.meta index c7cd99b..920d4b0 100644 --- a/assets/scripts/utils/tool.ts.meta +++ b/assets/resources/prefab/utils/prefabTool.ts.meta @@ -1,6 +1,6 @@ { "ver": "1.0.8", - "uuid": "cf64cfa3-9f26-4ef6-9a03-bf5a4a7a279d", + "uuid": "de8d3141-f302-4c3f-abdc-14ae99f832a0", "isPlugin": false, "loadPluginInWeb": true, "loadPluginInNative": true, diff --git a/assets/scene/gamesGoBang.fire b/assets/scene/gamesGoBang.fire index b90edd8..6b9fc9b 100644 --- a/assets/scene/gamesGoBang.fire +++ b/assets/scene/gamesGoBang.fire @@ -63,7 +63,7 @@ { "__type__": "cc.Node", "_name": "Canvas", - "_objFlags": 512, + "_objFlags": 0, "_parent": { "__id__": 1 }, @@ -515,7 +515,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "000000", "_N$string": "000000", "_fontSize": 40, @@ -770,7 +771,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "等待加入...", "_N$string": "等待加入...", "_fontSize": 20, @@ -1076,7 +1078,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "--:--", "_N$string": "--:--", "_fontSize": 30, @@ -1270,7 +1273,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "-", "_N$string": "-", "_fontSize": 30, @@ -1693,7 +1697,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "等待加入...", "_N$string": "等待加入...", "_fontSize": 20, @@ -1999,7 +2004,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "--:--", "_N$string": "--:--", "_fontSize": 30, @@ -2193,7 +2199,8 @@ "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" } ], - "_useOriginalSize": false, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "-", "_N$string": "-", "_fontSize": 30, @@ -2643,7 +2650,7 @@ 1, 0.742, 0.742, - 1 + 0 ] }, "_eulerAngles": { @@ -2902,7 +2909,6 @@ "_parent": { "__id__": 2 }, - "_id": "d0xrWUqwZN/7vHEHGOfrch", "_prefab": { "__id__": 65 }, @@ -2929,7 +2935,8 @@ "x": 0, "y": 0, "z": 0 - } + }, + "_id": "d0xrWUqwZN/7vHEHGOfrch" }, { "__type__": "cc.PrefabInfo", diff --git a/assets/scripts/Games/eliminating/script/Block.ts b/assets/scripts/Games/eliminating/script/Block.ts index 2398875..88783a2 100644 --- a/assets/scripts/Games/eliminating/script/Block.ts +++ b/assets/scripts/Games/eliminating/script/Block.ts @@ -1,6 +1,6 @@ import EliminatingBlock from './EliminatingBlock'; import EliminatingInterface from '../../../interface/game/eliminating'; -import { luanchOptions } from '../../../lib/tool'; +import { luanchOptions } from '../../../../scripts/lib/tool'; export default /** diff --git a/assets/scripts/Games/flightChess/flightChess.ts b/assets/scripts/Games/flightChess/flightChess.ts index c72f90d..1486ca3 100644 --- a/assets/scripts/Games/flightChess/flightChess.ts +++ b/assets/scripts/Games/flightChess/flightChess.ts @@ -14,7 +14,7 @@ import { FlightPlayersData } from '../../interface/game/flightChessInterface'; import axios from '../../utils/axiosUtils'; import State from '../../utils/state'; import { UserData } from '../../interface/game/fourCard'; -import { loadImg, setAutoRecursively } from '../../lib/tool'; +import { loadImg, setAutoRecursively } from '../../../scripts/lib/tool'; const FlightPlayer = cc.Class({ name: 'FlightPlayer', @@ -602,7 +602,7 @@ export default class FlightChess extends cc.Component { * 暂停游戏 */ stopGames() { - cc.loader.loadRes('prefab/subpack/stopGames', cc.Prefab, (_err, prefab) => { + cc.loader.loadRes('prefab/stopGames', cc.Prefab, (_err, prefab) => { if (prefab) { const popup = cc.instantiate(prefab); cc.director.getScene().addChild(popup); diff --git a/assets/scripts/Games/fourCards/FourCardsMain.ts b/assets/scripts/Games/fourCards/FourCardsMain.ts index 78087d1..c2f7388 100644 --- a/assets/scripts/Games/fourCards/FourCardsMain.ts +++ b/assets/scripts/Games/fourCards/FourCardsMain.ts @@ -11,7 +11,7 @@ const {ccclass, property} = cc._decorator; import axios from '../../utils/axiosUtils'; import State from '../../utils/state'; -import { loadImg, setAutoRecursively } from '../../lib/tool'; +import { loadImg, setAutoRecursively } from '../../../scripts/lib/tool'; import { CardList, FourCardsPlayers, SendCardData, UserData } from '../../interface/game/fourCard'; /** * 扑克牌 @@ -854,7 +854,7 @@ export default class FourCardsGame extends cc.Component { * 暂停游戏 */ stopGames() { - cc.loader.loadRes('prefab/subpack/stopGames', cc.Prefab, (err, prefab) => { + cc.loader.loadRes('prefab/stopGames', cc.Prefab, (err, prefab) => { if (prefab) { const popup = cc.instantiate(prefab); cc.director.getScene().addChild(popup); diff --git a/assets/scripts/Games/over/overScript.ts b/assets/scripts/Games/over/overScript.ts index f7a5148..6596222 100644 --- a/assets/scripts/Games/over/overScript.ts +++ b/assets/scripts/Games/over/overScript.ts @@ -9,7 +9,7 @@ // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; -import { dateFrom } from '../../lib/tool'; +import { dateFrom } from '../../../scripts/lib/tool'; import axios from '../../utils/axiosUtils'; const ItemData = cc.Class({ diff --git a/assets/scripts/Games/wzq/main.ts b/assets/scripts/Games/wzq/main.ts index 53153ae..77d0fec 100644 --- a/assets/scripts/Games/wzq/main.ts +++ b/assets/scripts/Games/wzq/main.ts @@ -11,7 +11,7 @@ const {ccclass, property} = cc._decorator; import State from '../../utils/state'; import axios from '../../utils/axiosUtils'; -import { setAutoRecursively, loadImg } from '../../lib/tool'; +import { setAutoRecursively, loadImg } from '../../../scripts/lib/tool'; /** * 玩家数据 @@ -116,7 +116,7 @@ export default class GoBangMainService extends cc.Component { * 暂停游戏 */ stopGames() { - cc.loader.loadRes('prefab/subpack/stopGames', cc.Prefab, (err, prefab) => { + cc.loader.loadRes('prefab/stopGames', cc.Prefab, (err, prefab) => { if (prefab) { const popup = cc.instantiate(prefab); cc.director.getScene().addChild(popup); diff --git a/assets/scripts/Home/Home.ts b/assets/scripts/Home/Home.ts index 457c4e5..d828ae9 100644 --- a/assets/scripts/Home/Home.ts +++ b/assets/scripts/Home/Home.ts @@ -9,11 +9,12 @@ // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html import { setAutoRecursively } from '../lib/tool'; -const {ccclass, property} = cc._decorator; import { screenFringe } from '../lib/tool'; import State from '../utils/state'; import axios from '../utils/axiosUtils'; import socket from '../lib/socketIO'; + +const {ccclass, property} = cc._decorator; // socket初始化 socket.init(); // 是否为第一次打开 @@ -54,7 +55,7 @@ export default class Home extends cc.Component { axios.api('room_exit').then(() => {}); // 如果非微信小游戏则不进行填充 - if (!State.IS_WECHAT) { + if (!CC_WECHATGAME) { this.rightTopBar.getComponent(cc.Widget).right = 0; } } @@ -85,7 +86,7 @@ export default class Home extends cc.Component { * @param gameName - 游戏名 */ openGame(_event, gameName: string) { - cc.loader.loadRes('prefab/GroupLoading', (_err, prefab) => { + cc.loader.loadRes('prefab/groupLoading', (_err, prefab) => { const instantiate = cc.instantiate(prefab); cc.director.getScene().addChild(instantiate); cc.director.preloadScene(gameName, (_err) => { diff --git a/assets/scripts/Home/Room/Room.prefab b/assets/scripts/Home/Room/Room.prefab index 7617a33..799016c 100644 --- a/assets/scripts/Home/Room/Room.prefab +++ b/assets/scripts/Home/Room/Room.prefab @@ -1402,7 +1402,7 @@ 1, 0.906, 0.864, - 1 + 0 ] }, "_eulerAngles": { @@ -2529,7 +2529,7 @@ 1, 0.491, 0.491, - 1 + 0 ] }, "_eulerAngles": { @@ -3963,7 +3963,7 @@ 1, 0.906, 0.864, - 1 + 0 ] }, "_eulerAngles": { @@ -6261,7 +6261,7 @@ "asset": { "__uuid__": "585911dc-0f63-46fb-9bf3-2f41ce2d2045" }, - "fileId": "32HA8aiEBGt5i+qGbUmTfx", + "fileId": "", "sync": false } ] \ No newline at end of file diff --git a/assets/scripts/Home/script/Business.ts b/assets/scripts/Home/script/Business.ts index bb2515b..ba79fa3 100644 --- a/assets/scripts/Home/script/Business.ts +++ b/assets/scripts/Home/script/Business.ts @@ -7,7 +7,7 @@ const {ccclass, property} = cc._decorator; // 第一次切换 -let onlyToggle = true; +// let onlyToggle = true; /** * 首页左侧商家脚本 diff --git a/assets/scripts/Home/script/HomeGames.ts b/assets/scripts/Home/script/HomeGames.ts index 1d82770..ec0775f 100644 --- a/assets/scripts/Home/script/HomeGames.ts +++ b/assets/scripts/Home/script/HomeGames.ts @@ -40,7 +40,7 @@ export default class HomeGames extends cc.Component { start() { axios.api('get_home_message').then(messageList => this.messageList = messageList); - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { onShow(this.wxShow, this); } // 加入房间检测 @@ -53,7 +53,7 @@ export default class HomeGames extends cc.Component { * 销毁时 */ onDestroy() { - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { offShow(this.wxShow, this); } } @@ -95,7 +95,7 @@ export default class HomeGames extends cc.Component { */ joinRoom() { const that = this; - cc.loader.loadRes('prefab/subpack/keyboard', cc.Prefab, (err, prefab) => { + cc.loader.loadRes('prefab/keyboard', cc.Prefab, (err, prefab) => { if (prefab) { const joinRoomPopup = cc.instantiate(prefab); cc.director.getScene().addChild(joinRoomPopup); diff --git a/assets/scripts/Home/script/Portrait.ts b/assets/scripts/Home/script/Portrait.ts index 49b8646..0cfad7c 100644 --- a/assets/scripts/Home/script/Portrait.ts +++ b/assets/scripts/Home/script/Portrait.ts @@ -11,7 +11,7 @@ const {ccclass, property} = cc._decorator; import State from '../../utils/state'; import axios from '../../utils/axiosUtils'; -import { loadImg } from '../../lib/tool'; +import { loadImg } from '../../../scripts/lib/tool'; import { Utils } from '../../interface/index'; @ccclass diff --git a/assets/scripts/Home/shop/shopItem.ts b/assets/scripts/Home/shop/shopItem.ts index e7aef07..872ece8 100644 --- a/assets/scripts/Home/shop/shopItem.ts +++ b/assets/scripts/Home/shop/shopItem.ts @@ -9,7 +9,7 @@ // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; -import { url, loadImg } from '../../lib/tool'; +import { url, loadImg } from '../../../scripts/lib/tool'; import { ShopItem } from '../../interface/shop'; import parentClass from './Shop'; diff --git a/assets/scripts/Home/user/userCenter-info.ts b/assets/scripts/Home/user/userCenter-info.ts index dd2cac9..bb4e3f3 100644 --- a/assets/scripts/Home/user/userCenter-info.ts +++ b/assets/scripts/Home/user/userCenter-info.ts @@ -10,7 +10,7 @@ const {ccclass, property} = cc._decorator; import State from '../../utils/state'; -import { loadImg, uploadFile } from '../../lib/tool'; +import { loadImg, uploadFile } from '../../../scripts/lib/tool'; import axios from '../../utils/axiosUtils'; @ccclass diff --git a/assets/scripts/Loading/loadingPackage.ts b/assets/scripts/Loading/loadingPackage.ts index 932d126..292f1a2 100644 --- a/assets/scripts/Loading/loadingPackage.ts +++ b/assets/scripts/Loading/loadingPackage.ts @@ -5,73 +5,85 @@ * @param callback - 回调 */ export default async function packLoading( - packages: { - sub?: string[], - scene?: string[], - }, - callback?: ( - targetPack: string, - /** - * 当前加载下标 - */ - successCount: number, - /** - * 加载总数 - */ - allCount: number, - /** - * 回执消息内容 - */ - message: string - ) => boolean, + packages: { + sub?: string[], + scene?: string[], + }, + callback?: ( + targetPack: string, + /** + * 当前加载下标 + */ + successCount: number, + /** + * 加载总数 + */ + allCount: number, + /** + * 回执消息内容 + */ + message: string + ) => boolean, ) { -// console.log(cc.loader); -// // console.log(Object.keys(cc.loader.downloader._subpackages).length); -// console.log(cc.assetManager.bundles); -// cc.loader.onProgress = (...params) => { -// console.log('onProgress', params); - -// } - -// if (Object.keys(cc.loader.downloader._subpackages).length === 0) { -// return callback && callback('skip', 1, 1, '跳过加载...'); -// } - const { scene, sub } = packages; - const allCount = scene.length + sub.length; + // console.log(cc.loader); + // // console.log(Object.keys(cc.loader.downloader._subpackages).length); + // console.log(cc.assetManager.bundles); + // cc.loader.onProgress = (...params) => { + // console.log('onProgress', params); - for (const subIndex in sub) { - const subName = sub[subIndex]; - await new Promise((resolve) => { - cc.loader.downloader.loadSubpackage(subName, (err) => { - if (err) { - return console.error(err); - } - resolve(); - callback && callback( - subName, - +subIndex + 1, - allCount, - `subPack/${subName}... [${+subIndex + 1}/${sub.length}]` - ); - }); - }) - } + // } - for (const sceneIndex in scene) { - const sceneName = scene[sceneIndex]; - await new Promise((resolve) => { - cc.director.preloadScene(sceneName, (err) => { - if (err) { - return console.error(err); - } - resolve(); - callback && callback( - sceneName, - +sceneIndex + 1 + sub.length, - allCount, - `scene/${sceneName}... [${+sceneIndex + 1}/${scene.length}]` - ); - }); - }) - } + // if (Object.keys(cc.loader.downloader._subpackages).length === 0) { + // return callback && callback('skip', 1, 1, '跳过加载...'); + // } + const { scene, sub } = packages; + const allCount = scene.length + sub.length; + + for (const subIndex in sub) { + const subName = sub[subIndex]; + await new Promise((resolve) => { + // cc.loader.downloader.loadSubpackage(subName, (err) => { + // if (err) { + // return console.error(err); + // } + // resolve(); + // callback && callback( + // subName, + // +subIndex + 1, + // allCount, + // `subPack/${subName}... [${+subIndex + 1}/${sub.length}]` + // ); + // }); + cc.resources.loadDir(subName, (err) => { + if (err) { + return console.error(err); + } + resolve(); + callback && callback( + subName, + +subIndex + 1, + allCount, + `subPack/${subName}... [${+subIndex + 1}/${sub.length}]` + ); + }) + }) + } + + for (const sceneIndex in scene) { + const sceneName = scene[sceneIndex]; + await new Promise((resolve) => { + cc.director.preloadScene(sceneName, (err) => { + if (err) { + return console.error(err); + } + resolve(); + callback && callback( + sceneName, + +sceneIndex + 1 + sub.length, + allCount, + `scene/${sceneName}... [${+sceneIndex + 1}/${scene.length}]` + ); + }); + }) + } }; \ No newline at end of file diff --git a/assets/scripts/lib.meta b/assets/scripts/lib.meta index 4fa6c0c..956e70a 100644 --- a/assets/scripts/lib.meta +++ b/assets/scripts/lib.meta @@ -3,7 +3,7 @@ "uuid": "47c8091c-dda5-4a6e-bf59-c29bd9231d5c", "isBundle": true, "bundleName": "", - "priority": 5, + "priority": "1", "compressionType": { "wechatgame": "subpackage", "baidugame": "subpackage", diff --git a/assets/scripts/lib/socketIO.ts b/assets/scripts/lib/socketIO.ts index 1339aa3..f76fcbe 100644 --- a/assets/scripts/lib/socketIO.ts +++ b/assets/scripts/lib/socketIO.ts @@ -30,13 +30,13 @@ * this.$io.gameIM.emit() * this.$io.gameIM.on() 等 Socket 方法 */ -// const io = require('../lib/socket.io.js'); -import * as io from './asocket.ioLib/asocket.io'; +const io = require('./asocket.ioLib/asocket.io.js'); +// import * as io from './asocket.ioLib/asocket.io.js'; // import State from './state'; -import State from '../utils/state'; -import defaultConfig from '../config/default.config'; -import axios from '../utils/axiosUtils'; -import { Utils } from '../interface/index'; +import State from '../../scripts/utils/state'; +import defaultConfig from '../../scripts/config/default.config'; +import axios from '../../scripts/utils/axiosUtils'; +import { Utils } from '../../scripts/interface/index'; // IO配置文件引入 const IoConfig = defaultConfig.io; diff --git a/assets/scripts/lib/tool.ts b/assets/scripts/lib/tool.ts index 6bc16fe..9e33cad 100644 --- a/assets/scripts/lib/tool.ts +++ b/assets/scripts/lib/tool.ts @@ -1,4 +1,4 @@ -import State from "../utils/state"; +import State from "../../scripts/utils/state"; // import axios from '../utils/axiosUtils'; /** @@ -81,7 +81,7 @@ export function loadImg(url, callback, type?: 'avatar', urlParams?: any, imgType * @param query 查询字符串,从这条转发消息进入后,可通过 wx.getLaunchOptionsSync() 或 wx.onShow() 获取启动参数中的 query。必须是 key1=val1&key2=val2 的格式。 */ export const shareAppMessage = (title: string, imageUrl?: string, query?: string | object) => { - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { wx.shareAppMessage({ title, imageUrl, @@ -98,7 +98,7 @@ export const shareAppMessage = (title: string, imageUrl?: string, query?: string export const uploadFile = (ossOption, fileName, unit?: string) => { return new Promise((reslove, reject) => { console.log(ossOption); - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { // 微信上传 wx.chooseImage({ success (res) { @@ -130,7 +130,7 @@ export const uploadFile = (ossOption, fileName, unit?: string) => { }, fial: reject, }); - } else if (State.IS_BROWSER) { + } else if (CC_PREVIEW) { const fileInput = document.createElement('input'); fileInput.type = 'file'; fileInput.click(); @@ -187,7 +187,7 @@ export const luanchOptions = (() => { imageUrl: State.OSS_BASE + '/H5Game/share/main.png', }; let options; - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { options = wx.getLaunchOptionsSync().query; wx.showShareMenu({ withShareTicket: true, @@ -227,7 +227,7 @@ export const screenFringe = (nodes: cc.Node[]) => { * @param that this指向 */ export const onShow = (callback, that = null) => { - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { wx.onShow(callback.bind(that)); } }; @@ -239,7 +239,7 @@ export const onShow = (callback, that = null) => { * @param that this指向 */ export const offShow = (callback, that = null) => { - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { wx.offShow(callback.bind(that)); } }; @@ -251,7 +251,7 @@ export const offShow = (callback, that = null) => { * @param that this指向 */ export const onHide = (callback, that = null) => { - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { wx.onHide(callback.bind(that)); } }; @@ -263,7 +263,7 @@ export const onHide = (callback, that = null) => { * @param that this指向 */ export const offHide = (callback, that = null) => { - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { wx.offHide(callback.bind(that)); } }; @@ -279,7 +279,7 @@ const fringeScreenModels = [ 'vivo Y83A', 'LLD-AL20', 'vivo Z1', 'PACM00', 'PAAM00' ]; export const hasScreenFringe = () => { - const systemInfo = State.IS_WECHAT ? wx.getSystemInfoSync() : { model: null }; + const systemInfo = CC_WECHATGAME ? wx.getSystemInfoSync() : { model: null }; if (systemInfo.model != null) { for (let i in fringeScreenModels) { @@ -300,4 +300,16 @@ export const hasScreenFringe = () => { // return true; // } return false; +} + + +/** + * 检测旋转屏幕 + */ +export const testingRotate = () => { + const { width, height } = cc.view.getFrameSize(); + cc.view.setFrameSize(width, width < height ? height / 3 : height); + if (width < height) { + alert('请横屏游玩!'); + } } \ No newline at end of file diff --git a/assets/scripts/loginPage/script/onWxLogin.ts b/assets/scripts/loginPage/script/onWxLogin.ts index 96cc2d0..5cac2fb 100644 --- a/assets/scripts/loginPage/script/onWxLogin.ts +++ b/assets/scripts/loginPage/script/onWxLogin.ts @@ -2,7 +2,7 @@ const {ccclass} = cc._decorator; import axios from '../../utils/axiosUtils'; import State from '../../utils/state'; -import { testingRotate } from '../../utils/tool'; +import { testingRotate } from '../../../scripts/lib/tool'; @ccclass export default class WxLogin extends cc.Component { @@ -16,7 +16,7 @@ export default class WxLogin extends cc.Component { const y = -161.41; const that = this; - if (State.IS_WECHAT) { + if (CC_WECHATGAME) { let sysInfo = window.wx.getSystemInfoSync(); //获取微信界面大小 let screenWidth = sysInfo.screenWidth; @@ -72,7 +72,7 @@ export default class WxLogin extends cc.Component { onClickLoginButton() { if (this.userInfo) { this.onWxLogin(this.userInfo); - } else if (!State.IS_WECHAT) { + } else if (!CC_WECHATGAME) { this.node.getComponent('loginPage').popupMiniContent('此功能只允许在\n微信小游戏或微信中使用!', 3000); } } diff --git a/assets/scripts/perfab/script/ListItem.ts b/assets/scripts/perfab/script/ListItem.ts index 6f00a97..0dda8b7 100644 --- a/assets/scripts/perfab/script/ListItem.ts +++ b/assets/scripts/perfab/script/ListItem.ts @@ -9,7 +9,7 @@ // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; -import { loadImg } from '../../lib/tool'; +import { loadImg } from '../../../scripts/lib/tool'; @ccclass export default class ListItem extends cc.Component { diff --git a/assets/scripts/perfab/script/signal.ts b/assets/scripts/perfab/script/signal.ts index 7b114aa..d5a8ac8 100644 --- a/assets/scripts/perfab/script/signal.ts +++ b/assets/scripts/perfab/script/signal.ts @@ -9,7 +9,7 @@ // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; -import { dateFrom } from '../../lib/tool'; +import { dateFrom } from '../../../scripts/lib/tool'; import State from '../../utils/state'; let prveStatus = 20; diff --git a/assets/scripts/utils/gameSetting.ts b/assets/scripts/utils/gameSetting.ts index d54e51b..6a05075 100644 --- a/assets/scripts/utils/gameSetting.ts +++ b/assets/scripts/utils/gameSetting.ts @@ -34,7 +34,7 @@ const _CONFIG_ = { fps: -1, }; const config = Object.keys(storage).length ? storage : _CONFIG_; -cc.game.setFrameRate(config.fps); +// cc.game.setFrameRate(60); export default new class System { /** diff --git a/assets/scripts/utils/state.ts b/assets/scripts/utils/state.ts index 3cee1f1..9f652be 100644 --- a/assets/scripts/utils/state.ts +++ b/assets/scripts/utils/state.ts @@ -1,4 +1,7 @@ // Learn TypeScript: +cc.assetManager.loadBundle('lib', (err, bundle) => { + // bundle.load('lib'); +}); /** * 缓存数据 * 负责数据缓存npm install --save socket.io-wxapp-client @@ -122,7 +125,7 @@ const State: Utils.State = { */ tips(content: string, timeout: number = 2, effect: boolean = false, icon = -1) { return new Promise((resolve, reject) => { - cc.loader.loadRes('prefab/Tips', cc.Prefab, (_err, prefab) => { + cc.loader.loadRes('prefab/tips', cc.Prefab, (_err, prefab) => { if (prefab) { const popup = cc.instantiate(prefab); cc.director.getScene().addChild(popup); diff --git a/assets/scripts/utils/tool.ts b/assets/scripts/utils/tool.ts deleted file mode 100644 index 075ab42..0000000 --- a/assets/scripts/utils/tool.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * 检测旋转屏幕 - */ -export const testingRotate = () => { - const { width, height } = cc.view.getFrameSize(); - cc.view.setFrameSize(width, width < height ? height / 3 : height); - if (width < height) { - alert('请横屏游玩!'); - } -} \ No newline at end of file diff --git a/settings/builder.json b/settings/builder.json index 2b310f8..9eb358d 100644 --- a/settings/builder.json +++ b/settings/builder.json @@ -21,15 +21,25 @@ "zipCompressJs": true, "fb-instant-games": {}, "android": { + "REMOTE_SERVER_ROOT": "", "packageName": "" }, "ios": { + "REMOTE_SERVER_ROOT": "", + "ios_enable_jit": true, "packageName": "" }, "mac": { - "packageName": "" + "REMOTE_SERVER_ROOT": "", + "height": 720, + "packageName": "", + "width": 1280 + }, + "win32": { + "REMOTE_SERVER_ROOT": "", + "height": 720, + "width": 1280 }, - "win32": {}, "android-instant": { "REMOTE_SERVER_ROOT": "http://192.168.2.20:7456/preview-android-instant/", "host": "", @@ -40,5 +50,12 @@ "skipRecord": false }, "appBundle": false, - "includeAnySDK": null + "includeAnySDK": null, + "mainCompressionType": "subpackage", + "mainIsRemote": false, + "nativeMd5Cache": true, + "agreements": { + "20200904180716": false, + "20200904180755": false + } } diff --git a/settings/project.json b/settings/project.json index ea8ad00..3171f6e 100644 --- a/settings/project.json +++ b/settings/project.json @@ -22,7 +22,7 @@ "3D Particle", "SafeArea" ], - "last-module-event-record-time": 1593935614764, + "last-module-event-record-time": 1613744260445, "design-resolution-width": 960, "design-resolution-height": 640, "fit-width": false, diff --git a/settings/services.json b/settings/services.json index 3edcc5e..707c8dc 100644 --- a/settings/services.json +++ b/settings/services.json @@ -25,6 +25,14 @@ "store_id_platform": "", "plugin_version": "1.3.7_2.2.1" } + }, + { + "service_id": "304", + "enable": false + }, + { + "service_id": "278", + "enable": false } ] } diff --git a/settings/wechatgame.json b/settings/wechatgame.json index a2ac341..ba12059 100644 --- a/settings/wechatgame.json +++ b/settings/wechatgame.json @@ -1,7 +1,8 @@ { "appid": "wx0d616764c4b2b96a", "orientation": "landscape", - "separate_engine": false, - "REMOTE_SERVER_ROOT": "https://slmblog.com/yh/public", - "subContext": "" + "separate_engine": true, + "REMOTE_SERVER_ROOT": "", + "subContext": "", + "startSceneAssetBundle": false }