适配
This commit is contained in:
parent
33000460c9
commit
009ccb1931
|
|
@ -12477,7 +12477,7 @@
|
|||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "0089d8d5-1af7-49f8-9d65-7a958b73a895"
|
||||
"__uuid__": "8699379d-f029-4548-81f3-b5560ac153e1"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
|
|
@ -17582,7 +17582,7 @@
|
|||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "0ddbaa55-7724-43ec-a9e5-7d80a31edacf"
|
||||
"__uuid__": "b51c6577-3f31-4777-bf4a-6bfad58f0612"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
|
|
@ -19894,8 +19894,8 @@
|
|||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 328,
|
||||
"height": 66
|
||||
"width": 251,
|
||||
"height": 71
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
|
|
@ -26351,7 +26351,7 @@
|
|||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 1080,
|
||||
"width": 2000,
|
||||
"height": 2600
|
||||
},
|
||||
"_anchorPoint": {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -352,6 +352,67 @@ export default class JiaZai extends cc.Component {
|
|||
console.log("HomeScene广告预加载初始化失败");
|
||||
}
|
||||
});
|
||||
|
||||
this.setAdaptation();
|
||||
}
|
||||
|
||||
setAdaptation() {
|
||||
const hmScale = cc.fx.GameTool.adaptation()
|
||||
|
||||
if (hmScale == 1) return;
|
||||
console.log("HomeSceneScale", this.node.scale, hmScale);
|
||||
const loadNode = this.node.getChildByName("Load");
|
||||
if (loadNode) {
|
||||
// 获取屏幕设计分辨率
|
||||
const designSize = cc.view.getDesignResolutionSize();
|
||||
// 获取实际屏幕尺寸
|
||||
const frameSize = cc.view.getFrameSize();
|
||||
// 计算缩放因子
|
||||
const scaleX = frameSize.width / designSize.width;
|
||||
const scaleY = frameSize.height / designSize.height;
|
||||
// 取最小缩放因子保持比例
|
||||
const scale = Math.min(scaleX, scaleY);
|
||||
|
||||
// 计算黑边宽度 (如果有的话)
|
||||
let barWidth = 0;
|
||||
if (scaleX > scaleY) {
|
||||
// 左右有黑边
|
||||
barWidth = (frameSize.width - designSize.width * scale) / 2;
|
||||
}
|
||||
|
||||
loadNode.scale = hmScale;
|
||||
|
||||
// 适配右边的元素,保持与右边框距离不变
|
||||
const rightElements = [
|
||||
"tiaodik",
|
||||
"shezhiBtn",
|
||||
"rank",
|
||||
"Pause",
|
||||
"topRank"
|
||||
];
|
||||
|
||||
rightElements.forEach(elementName => {
|
||||
let element;
|
||||
if (elementName === "rank" || elementName === "Pause") {
|
||||
element = this.node.getChildByName(elementName);
|
||||
} else if (elementName === "topRank") {
|
||||
element = loadNode.getChildByName("rank");
|
||||
} else {
|
||||
element = loadNode.getChildByName(elementName);
|
||||
}
|
||||
|
||||
if (element) {
|
||||
// 保存原始x位置作为距离右边的距离参考
|
||||
if (!element.originalRightOffset) {
|
||||
element.originalRightOffset = designSize.width / 2 - element.x;
|
||||
}
|
||||
|
||||
// 根据屏幕适配调整位置,保持与右边框距离一致
|
||||
element.x = designSize.width / 2 - element.originalRightOffset + barWidth / scale;
|
||||
element.scale = hmScale;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
checkDailyQuests() {
|
||||
|
|
@ -438,9 +499,10 @@ export default class JiaZai extends cc.Component {
|
|||
let pauseNode = health.getChildByName("heath");
|
||||
cc.fx.AudioManager._instance.playEffect("tanchuang", null);
|
||||
pauseNode.scale = 0.3;
|
||||
const hmScale = cc.fx.GameTool.adaptation()
|
||||
cc.tween(pauseNode)
|
||||
.to(0.2, { scale: 1.05 }, { easing: 'backOut' })
|
||||
.to(0.15, { scale: 1.0 }, { easing: 'sineOut' })
|
||||
.to(0.2, { scale: 1.05 * hmScale }, { easing: 'backOut' })
|
||||
.to(0.15, { scale: 1.0 * hmScale }, { easing: 'sineOut' })
|
||||
.start();
|
||||
// 启动弹窗自己的倒计时
|
||||
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
|
||||
|
|
|
|||
|
|
@ -540,9 +540,9 @@ export default class MapConroler extends cc.Component {
|
|||
}
|
||||
|
||||
// 开始游戏时 清空道具 如果是第 8 11 16 默认给一个道具
|
||||
cc.fx.GameConfig.GM_INFO.hammerAmount = 5;
|
||||
cc.fx.GameConfig.GM_INFO.freezeAmount = 5;
|
||||
cc.fx.GameConfig.GM_INFO.magicAmount = 5;
|
||||
cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
|
||||
cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
|
||||
cc.fx.GameConfig.GM_INFO.magicAmount = 0;
|
||||
if (cc.fx.GameConfig.GM_INFO.level + 1 == 8) {
|
||||
cc.fx.GameConfig.GM_INFO.hammerAmount = 1;
|
||||
}
|
||||
|
|
@ -2183,7 +2183,7 @@ export default class MapConroler extends cc.Component {
|
|||
console.log("复活回调函数内", data);
|
||||
this.isreview = true;
|
||||
const dataTemp = {
|
||||
change_reason: "share",
|
||||
change_reason: "ad",
|
||||
id: "2000",
|
||||
num: 1
|
||||
}
|
||||
|
|
@ -3523,10 +3523,35 @@ export default class MapConroler extends cc.Component {
|
|||
}
|
||||
|
||||
// this.node.scale = 1;
|
||||
cc.fx.GameConfig.GM_INFO.scale = this.node.scale;
|
||||
// this.node.scale = 0.5;
|
||||
// console.log(this.node.scale);
|
||||
// this.node.scale = 1;
|
||||
|
||||
const gmScale = cc.fx.GameTool.adaptation()
|
||||
this.node.scale = this.node.scale * gmScale;
|
||||
|
||||
const topNode = this.node.parent.getChildByName("Top");
|
||||
topNode.scale = gmScale;
|
||||
if (topNode) {
|
||||
if (gmScale == 0.7) {
|
||||
// 修改Widget的top属性
|
||||
const widget = topNode.getComponent(cc.Widget);
|
||||
if (widget) {
|
||||
widget.top -= 60; // 减去偏移量使节点向上移动
|
||||
widget.updateAlignment(); // 强制更新对齐
|
||||
}
|
||||
this.node.y = this.node.y + 40;
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
this.node.parent.parent.getChildByName("Win").scale = gmScale;
|
||||
this.node.parent.parent.getChildByName("Lose").scale = gmScale;
|
||||
this.node.parent.parent.getChildByName("propWindow").scale = gmScale;
|
||||
this.node.parent.parent.getChildByName("guidet").scale = gmScale;
|
||||
this.node.parent.parent.parent.getChildByName("Pause").scale = gmScale;
|
||||
|
||||
cc.fx.GameConfig.GM_INFO.scale = this.node.scale;
|
||||
}
|
||||
|
||||
//创建门的粒子特效
|
||||
|
|
|
|||
|
|
@ -24,11 +24,6 @@ export default class NewClass extends cc.Component {
|
|||
@property([cc.Node])
|
||||
switchButtons: cc.Node[] = [];
|
||||
|
||||
@property(cc.Sprite)
|
||||
share_img: cc.Sprite = null;
|
||||
|
||||
@property(cc.Sprite)
|
||||
ad_img: cc.Sprite = null;
|
||||
//金币花费数
|
||||
// @property(cc.Node)
|
||||
// coin: cc.Node = null;
|
||||
|
|
@ -37,19 +32,23 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
onLoad() {
|
||||
this.btn_Touch = true;
|
||||
if (cc.fx.GameTool.canObtainByShare("health")) {
|
||||
this.share_img.node.active = true;
|
||||
|
||||
this.ad_img.node.active = false;
|
||||
} else {
|
||||
this.share_img.node.active = false;
|
||||
|
||||
this.ad_img.node.active = true;
|
||||
}
|
||||
}
|
||||
start() {
|
||||
this.btn_Touch = true;
|
||||
this.openPop();
|
||||
this.initUI();
|
||||
}
|
||||
|
||||
initUI() {
|
||||
if (this.switchButtons[1] && this.switchButtons[1].childrenCount > 1) {
|
||||
if (cc.fx.GameTool.canObtainByShare("health")) {
|
||||
this.switchButtons[1].getChildByName("share_img").active = true;
|
||||
this.switchButtons[1].getChildByName("ad_img").active = false;
|
||||
} else {
|
||||
this.switchButtons[1].getChildByName("share_img").active = false;
|
||||
this.switchButtons[1].getChildByName("ad_img").active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//打开商店界面
|
||||
openPop() {
|
||||
|
|
@ -86,7 +85,7 @@ export default class NewClass extends cc.Component {
|
|||
// if (curCoin >= 1000) {
|
||||
// cc.fx.GameConfig.GM_INFO.hp = 1; // 测试时不通过微信分享使用
|
||||
|
||||
var callback = function (isType) {
|
||||
var callback = function (isType, shareOrAd) {
|
||||
//// 分享成功后才执行以下代码
|
||||
if (isType == true) {
|
||||
console.log("分享得体力");
|
||||
|
|
@ -108,6 +107,15 @@ export default class NewClass extends cc.Component {
|
|||
})
|
||||
|
||||
cc.fx.GameTool.addShareCount("health")
|
||||
|
||||
const data = {
|
||||
change_reason: shareOrAd, // share or ad
|
||||
id: 1002,
|
||||
num: 1,
|
||||
compensate: false
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ var GameTool = {
|
|||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
|
||||
var cb = function (isType) {
|
||||
var cb = function (isType, shareOrAd) {
|
||||
if (isType) {
|
||||
let num = 1; //3
|
||||
|
||||
|
|
@ -696,7 +696,7 @@ var GameTool = {
|
|||
})
|
||||
|
||||
const data = {
|
||||
change_reason: "share",
|
||||
change_reason: shareOrAd, // share or ad
|
||||
id: propid,
|
||||
num: num,
|
||||
compensate: false
|
||||
|
|
@ -1405,7 +1405,7 @@ var GameTool = {
|
|||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
callback(true); // 回调表示分享成功
|
||||
callback(true, "share"); // 回调表示分享成功
|
||||
};
|
||||
|
||||
// 分享失败的处理函数
|
||||
|
|
@ -1548,7 +1548,7 @@ var GameTool = {
|
|||
data.is_complete_play = true;
|
||||
MiniGameSdk.API.showToast('用户看完广告,可以奖励');
|
||||
cc.fx.GameTool.shushu_Track("ad_close", data);
|
||||
callback(true);
|
||||
callback(true, "ad");
|
||||
// 广告观看成功后,立即开始下一次预加载
|
||||
cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
break;
|
||||
|
|
@ -1749,5 +1749,29 @@ var GameTool = {
|
|||
});
|
||||
},
|
||||
|
||||
// 适配
|
||||
adaptation: function () {
|
||||
// 获取屏幕尺寸
|
||||
const screenSize = cc.winSize;
|
||||
const screenWidth = screenSize.width;
|
||||
const screenHeight = screenSize.height;
|
||||
|
||||
// 设计分辨率
|
||||
const designWidth = 640;
|
||||
const designHeight = 960;
|
||||
|
||||
// 计算屏幕和设计比例
|
||||
const screenRatio = screenWidth / screenHeight;
|
||||
const designRatio = designWidth / designHeight;
|
||||
|
||||
// console.log("屏幕尺寸:" + screenWidth + "x" + screenHeight + " 比例:" + screenRatio + " 设计比例:" + designRatio);
|
||||
if (screenRatio > designRatio) {
|
||||
// 平板设备使用0.7倍缩放
|
||||
return 0.7;
|
||||
} else {
|
||||
// 其他设备使用正常1倍缩放
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
};
|
||||
export { GameTool };
|
||||
|
|
@ -395,7 +395,7 @@
|
|||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "68f1b13a-0814-4df0-be3b-f21d7e348355"
|
||||
"__uuid__": "bf466385-9217-4638-9303-06ab8e162fb8"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
|
|
@ -412,7 +412,7 @@
|
|||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "080952L8J5OuKlcs1LLoVSM",
|
||||
"__type__": "88e82r7InJI2oeFz0fji7XQ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user