加入微信全面屏顶部适配

This commit is contained in:
caizhitao
2019-05-05 21:04:32 +08:00
parent 7477d21ee1
commit 04e8bb3deb
13 changed files with 733 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
{
"ver": "0.9.0",
"ver": "1.0.1",
"uuid": "c977690b-8aaf-42cf-b711-59442ee83f1b",
"asyncLoadAssets": false,
"autoReleaseAssets": false,

View File

@@ -1,5 +1,5 @@
{
"ver": "0.9.0",
"ver": "1.0.1",
"uuid": "de960b3b-80fb-48e4-bcd5-fb3a72e14248",
"asyncLoadAssets": false,
"autoReleaseAssets": false,

View File

@@ -1,5 +1,5 @@
{
"ver": "0.9.0",
"ver": "1.0.1",
"uuid": "766a504a-cd28-4fe0-b65b-152472c18051",
"asyncLoadAssets": false,
"autoReleaseAssets": false,

View File

@@ -1,5 +1,5 @@
{
"ver": "0.9.0",
"ver": "1.0.1",
"uuid": "41ec7af2-39e4-4049-aeaa-6e7369a7481e",
"asyncLoadAssets": false,
"autoReleaseAssets": false,

View File

@@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "8ff9ca50-ee14-4f40-abd9-d182fef57cd0",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

View File

@@ -0,0 +1,551 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_level": 0,
"_components": [],
"_prefab": null,
"_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,
"y": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 0.4471873680914596,
"y": 0.4471873680914596,
"z": 1
},
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"groupIndex": 0,
"autoReleaseAssets": false,
"_id": "382679c3-213d-4f85-bfd1-d882017f02c2"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_level": 0,
"_components": [
{
"__id__": 14
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 720,
"height": 1280
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 360,
"y": 640,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "a3b+ULp75ItrlCyJOkgzv7"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 4
}
],
"_prefab": null,
"_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
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "23BmlpxRhKtr4IBmZd+peI"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_id": "42rRuNqUFGSaYdljko2RfW"
},
{
"__type__": "cc.Node",
"_name": "Content",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 6
},
{
"__id__": 9
}
],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 13
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 720,
"height": 1280
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "12aceVn49MMqnw+1ISH7RZ"
},
{
"__type__": "cc.Node",
"_name": "Background",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_children": [],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 720,
"height": 1280
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "9c6C1I2qZKR4dKG82tHSX4"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_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,
"_state": 0,
"_atlas": null,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_id": "7f9IkXBbVNNLdku2Dvkj6u"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_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": "22JcXTxyFGlbJq4yaidEwg"
},
{
"__type__": "cc.Node",
"_name": "TopBar",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_children": [],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 10
},
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 720,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "2cZSHwXHROfbxrRa5tp4kh"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"_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,
"_state": 0,
"_atlas": null,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_id": "68HB3qT4RIo4y8eRL1MsYd"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 40,
"_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": 0,
"_id": "87nyCXR+BEhIPmUFCjbRab"
},
{
"__type__": "7d5c1zrSXtFCIBi0S2Qe5E4",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"_id": "b6ypfhR5ZAK5+9II8hc/w1"
},
{
"__type__": "4010diIR0ZMhJ1/d++3vQ8Y",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_id": "0faiLcWNxNTYYInSsVzurp"
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 720,
"height": 1280
},
"_fitWidth": true,
"_fitHeight": true,
"_id": "a2T5YsG0tGza7tn2NUuOQI"
}
]

View File

@@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "382679c3-213d-4f85-bfd1-d882017f02c2",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

View File

@@ -0,0 +1,44 @@
// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
export default class WXGameTopBarUIAdapter extends cc.Component {
start() {
if (CC_WECHATGAME) {
let menuInfo = wx.getMenuButtonBoundingClientRect();
let systemInfo = wx.getSystemInfoSync();
// @see https://developers.weixin.qq.com/minigame/dev/api/wx.getSystemInfoSync.html
// @see https://developers.weixin.qq.com/minigame/dev/api/wx.getMenuButtonBoundingClientRect.html
// 因为微信小游戏是全屏的,所以我们用 systemInfo.screenHeight ,而不是 systemInfo.windoeHeight不过理论上这两个值在微信小游戏上是一样的
// 获取菜单按钮(右上角胶囊按钮)距离屏幕顶部的距离。这个值是微信像素值,是经过设备像素比后的值,需要转换一下才能得到原始像素值
// 但是转换过程我们不探讨
// 我们只需要用这个原始值除以在该设备像素比下的屏幕高度,得到相应比例,然后我们在用本节点的父节点高度乘一下,那么最后就是得到我们需要的屏幕顶部距离了
// this.node.parent 是我做了全屏适配后的节点,所以 .height 就是我这边适配后的屏幕高度
let paddingTop = this.node.parent.height * (menuInfo.top / systemInfo.screenHeight);
// 原理同上,我只是将本节点改为和微信菜单栏一样的高度
this.node.height = this.node.parent.height * (menuInfo.height / systemInfo.screenHeight);
// 这里采用 Widget 去调整本节点的位置
// 因为 Widget 会自动帮我们处理好不同锚点位置,省事,同时也考虑周全
// 如果单纯减 this.node.height / 2那么问题来了为什么是 / 2 而不是除以其他值,答案就是我们的锚点为 0.5,那么如果锚点为 0.3 等等其他值那么就不能除以2了
// 如果你能理解这段注释那么不用Widget也可以这里不再讨论
let widget = this.node.getComponent(cc.Widget);
widget.top = paddingTop;
widget.isAbsoluteTop = true;
widget.isAlignTop = true;
widget.updateAlignment();
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "7d5c1ceb-497b-4508-8062-d12d907b9138",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

49
settings/builder.json Normal file
View File

@@ -0,0 +1,49 @@
{
"android-instant": {
"REMOTE_SERVER_ROOT": "",
"host": "",
"pathPattern": "",
"recordPath": "",
"scheme": "https",
"skipRecord": false
},
"appBundle": false,
"baidugame": {
"REMOTE_SERVER_ROOT": "",
"appid": "testappid",
"orientation": "portrait",
"subContext": ""
},
"encryptJs": true,
"excludeScenes": [],
"fb-instant-games": {},
"includeSDKBox": false,
"inlineSpriteFrames": true,
"inlineSpriteFrames_native": true,
"md5Cache": false,
"mergeStartScene": false,
"optimizeHotUpdate": false,
"orientation": {
"landscapeLeft": true,
"landscapeRight": true,
"portrait": false,
"upsideDown": false
},
"packageName": "org.cocos2d.MultiResolutionAdaptation",
"qqplay": {
"REMOTE_SERVER_ROOT": "",
"orientation": "portrait",
"zip": false
},
"startScene": "382679c3-213d-4f85-bfd1-d882017f02c2",
"title": "MultiResolutionAdaptation",
"webOrientation": "auto",
"wechatgame": {
"REMOTE_SERVER_ROOT": "",
"appid": "wx6ac3f5090a6b99c5",
"orientation": "portrait",
"subContext": ""
},
"xxteaKey": "e9c779c9-7633-45",
"zipCompressJs": true
}

View File

@@ -1,34 +1,35 @@
{
"start-scene": "current",
"group-list": [
"default"
],
"assets-sort-type": "name",
"collision-matrix": [
[
true
]
],
"excluded-modules": [],
"last-module-event-record-time": 0,
"design-resolution-width": 960,
"design-resolution-height": 640,
"fit-width": false,
"fit-height": true,
"use-project-simulator-setting": false,
"simulator-orientation": false,
"use-customize-simulator": false,
"simulator-resolution": {
"width": 960,
"height": 640
},
"design-resolution-width": 960,
"excluded-modules": [],
"facebook": {
"enable": false,
"appID": "",
"live": {
"enable": false
},
"audience": {
"enable": false
},
"enable": false,
"live": {
"enable": false
}
}
},
"fit-height": true,
"fit-width": false,
"group-list": [
"default"
],
"last-module-event-record-time": 1557060764889,
"simulator-orientation": false,
"simulator-resolution": {
"height": 640,
"width": 960
},
"start-scene": "current",
"use-customize-simulator": false,
"use-project-simulator-setting": false
}

View File

@@ -16,8 +16,8 @@
"iOS",
"HTML5"
],
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-analytics/1.1.6_2.0.1_2.0.2.zip",
"package_version_desc": "1、 更新 H5 SDK 版本至 2.0.2。<br>2、 去除 AppSecret 参数。<br>3、appid 参数自动选择当前游戏绑定的游戏 appid。<br>4、 如有相关问题咨询或者需求, 可以联系我们技术支持邮箱 <a href=' '>support-cocos@cocos.com</a>",
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-analytics/1.1.7_2.0.3.zip",
"package_version_desc": "1、 更新 H5 SDK 版本至 2.0.3。<br>2、 SDK 优化更新,删除 init 接口字段 'channel' ,改为 login 接口输入。<br>3、 如有相关问题咨询或者需求, 可以联系我们技术支持邮箱 <a href=' '>support-cocos@cocos.com</a>",
"service_component_name": "service-analytics",
"package_versions": [
"1.0.0_1.0.5",
@@ -25,7 +25,8 @@
"1.1.3_2.0.1",
"1.1.4_2.0.1",
"1.1.5_2.0.1",
"1.1.6_2.0.1_2.0.2"
"1.1.6_2.0.1_2.0.2",
"1.1.7_2.0.3"
],
"build_platform": [
"web-mobile",
@@ -46,7 +47,7 @@
{
"service_id": "241",
"service_name": "Matchvs",
"service_desc": "通过SDK接入快速实现联网功能、帧同步、国内外多节点、服务器独立部署、gameServer自定义游戏服务端逻辑。\n技术支持群QQ群450335262",
"service_desc": "通过SDK接入快速实现联网功能、帧同步、国内外多节点、服务器独立部署、gameServer自定义游戏服务端逻辑。\n技术支持群QQ群822523258",
"service_title": "专业成熟的移动游戏联网与服务端解决方案",
"service_icon": "https://account.cocos.com/client/14406719a07eb3d714d36e5edc6e06fa.png",
"service_guide_url": "http://doc.matchvs.com/QuickStart/QuickStart-CocosCreator",
@@ -59,12 +60,13 @@
"iOS",
"HTML5"
],
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-matchvs/1.0.5_3.7.7.3.zip",
"package_version_desc": "2019-01-17<br> SDK版本v3.7.7.3 <br> 1. 增加 断线补帧接口 getOffLineData <br> 2. 修改 login 接口和 init 接口参数,去掉重复参数。 <br> 3. 修复 sendEvent 有新用户刚刚进入房间的时候收不到第一条消息。 <br> 4. 修改 接口调用返回错误码,内部逻辑修改,功能不变。 <br> 5. 增加 组队匹配 接口<br> 6. 修复 组队开始匹配开始一次后不能再次匹配问题。 <br> 7. 其他内部代码的一些优化。<br> ",
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-matchvs/1.0.6_3.7.9.2.zip",
"package_version_desc": "更新日期:2019-03-20<br>更新内容:<br>1、添加多节点相关接口 <br>2、优化独立部署wss和ws切换<br>3、优化login参数容错<br>4、添加组队中踢人和消息发送接口<br>5、添加取消组队匹配接口",
"service_component_name": "service-matchvs",
"package_versions": [
"1.0.3_3.7.6.4",
"1.0.5_3.7.7.3"
"1.0.5_3.7.7.3",
"1.0.6_3.7.9.2"
],
"build_platform": [
"web-mobile",
@@ -82,6 +84,35 @@
"huawei"
]
},
{
"service_id": "242",
"service_name": "Agora Voice",
"service_desc": "稳定、低耗、76ms超低延时、全球200+数据中心覆盖变声器、超高音质、听声辩位等丰富玩法极速接入全平台支持Android、iOS、Web。\n技术支持群QQ群799099183",
"service_title": "游戏内置实时语音SDK",
"service_icon": "https://account.cocos.com/uploads/client_icon/date(\"Y-m-d\")/50fe52b789c2fc1e1fff9eec161c1bb3.png",
"service_guide_url": "https://docs.agora.io/cn/Interactive Gaming/game_c",
"service_sample_url": " https://github.com/AgoraIO/Voice-Call-for-Mobile-Gaming/tree/master/Basic-Voice-Call-for-Gaming/Hello-Cocos-Creator-Voice-Agora",
"service_dev_url": "https://sso.agora.io/api/oauth/cocos/login",
"service_type": "3",
"service_type_zh": "公司和个人游戏",
"support_platform": [
"Android",
"iOS",
"HTML5"
],
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-agora/1.0.1_2.2.3.20_2.5.2.zip",
"package_version_desc": "first release.",
"service_component_name": "service-agora",
"package_versions": [
"1.0.1_2.2.3.20_2.5.2"
],
"build_platform": [
"web-mobile",
"web-desktop",
"android",
"ios"
]
},
{
"service_id": "7",
"service_name": "AnySDK",
@@ -91,8 +122,8 @@
"service_guide_url": "http://docs.anysdk.com",
"service_sample_url": "http://github.com/AnySDK",
"service_dev_url": "http://dev.anysdk.com",
"service_type": "2",
"service_type_zh": "支持公司游戏",
"service_type": "0",
"service_type_zh": "支持游戏",
"support_platform": [
"Android",
"iOS",

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 KiB