修改推荐流直玩上传加载完成的位置,修改通行证关闭效果背景白色问题

This commit is contained in:
huanghaipeng 2026-03-10 17:34:11 +08:00
parent 498ab8d3bf
commit 15b327d196
6 changed files with 141 additions and 145 deletions

View File

@ -52,7 +52,6 @@ export default class JiaZai extends cc.Component {
private isGetSidebar: boolean = false; private isGetSidebar: boolean = false;
@property(cc.EditBox) @property(cc.EditBox)
custom: cc.EditBox = null; custom: cc.EditBox = null;
@ -651,16 +650,6 @@ export default class JiaZai extends cc.Component {
top.getChildByName("hammer").active = false; top.getChildByName("hammer").active = false;
} }
this.setAdaptation(); this.setAdaptation();
// 加载广告
// cc.fx.GameTool.preloadRewardedVideoAd().then((success) => {
// if (success) {
// console.log("HomeScene广告预加载初始化成功");
// } else {
// console.log("HomeScene广告预加载初始化失败");
// }
// });
// 上报游戏加载完成时机(推荐流直玩需要)
cc.fx.GameTool.reportLoadComplete();
} }
// 适配pad // 适配pad
@ -3826,27 +3815,14 @@ export default class JiaZai extends cc.Component {
sidebarBtn.active = false; sidebarBtn.active = false;
} }
dy_kefu.active = true; dy_kefu.active = true;
// 检测推荐流直玩场景
const recommendFeedResult = cc.fx.GameTool.checkRecommendFeedLaunch();
console.log("推荐流直玩场景检测结果", recommendFeedResult); // 检测推荐流直玩场景(只在首次进入游戏时自动进入房间)
if (recommendFeedResult && recommendFeedResult.isRecommendFeedLaunch) { const recommendFeedResult = cc.fx.GameTool.checkRecommendFeedLaunch();
// 检查 tt.getRecommendFeedInfo 是否存在 // 安全检查,确保 cc.fx.GameConfig.GM_INFO 已初始化
//@ts-ignore const hasAutoEntered = cc.fx && cc.fx.GameConfig && cc.fx.GameConfig.GM_INFO ? cc.fx.GameConfig.GM_INFO.hasAutoEntered : false;
if (tt && tt.getRecommendFeedInfo) { if (!hasAutoEntered && recommendFeedResult && recommendFeedResult.isRecommendFeedLaunch) {
//@ts-ignore // 推荐流直玩,自动进入游戏房间
tt.getRecommendFeedInfo({ this.startGame();
success: (res) => {
console.log("推荐流信息:", res);
// 处理推荐流信息
},
fail: (err) => {
console.error("获取推荐流信息失败:", err);
}
});
} else {
console.log("tt.getRecommendFeedInfo 方法不可用,跳过获取推荐流信息");
}
} }
// 初始化推荐流直玩监听器 // 初始化推荐流直玩监听器

View File

@ -34,6 +34,16 @@ export default class NewClass extends cc.Component {
cc.debug.setDisplayStats(false); cc.debug.setDisplayStats(false);
let manager = cc.director.getCollisionManager(); let manager = cc.director.getCollisionManager();
manager.enabled = true; manager.enabled = true;
// 初始化推荐流自动进入标记(延迟初始化,确保 cc.fx 已加载)
setTimeout(() => {
if (cc.fx && cc.fx.GameConfig && cc.fx.GameConfig.GM_INFO) {
if (!cc.fx.GameConfig.GM_INFO.hasAutoEntered) {
cc.fx.GameConfig.GM_INFO.hasAutoEntered = false;
}
}
}, 100);
this.setWX(); this.setWX();
// let version = cc.fx.GameTool.getWechatGameVersion(); // let version = cc.fx.GameTool.getWechatGameVersion();

View File

@ -294,9 +294,12 @@ export default class MapConroler extends cc.Component {
} }
} }
}, cc.fx.GameConfig.GM_INFO.address); }, cc.fx.GameConfig.GM_INFO.address);
} }
start() { start() {
setTimeout(() => { setTimeout(() => {
cc.director.preloadScene("HomeScene", (err, asset) => { cc.director.preloadScene("HomeScene", (err, asset) => {
if (err) { if (err) {
@ -315,14 +318,14 @@ export default class MapConroler extends cc.Component {
// this.particleEffects = GameManager._instance.particleEffects; // this.particleEffects = GameManager._instance.particleEffects;
this.initMap(); this.initMap();
// 加载广告 // 上报游戏加载完成时机(推荐流直玩需要)
// cc.fx.GameTool.preloadRewardedVideoAd().then((success) => { cc.fx.GameTool.reportLoadComplete();
// if (success) {
// console.log("GameScene广告预加载初始化成功"); // 标记已经自动进入过房间(安全检查)
// } else { if (cc.fx && cc.fx.GameConfig && cc.fx.GameConfig.GM_INFO) {
// console.log("GameScene广告预加载初始化失败"); cc.fx.GameConfig.GM_INFO.hasAutoEntered = true;
// } }
// });
} }
//道具数量 //道具数量
setPropNum() { setPropNum() {

View File

@ -450,8 +450,8 @@ var GameTool = {
//关卡上限 //关卡上限
maxLevel() { maxLevel() {
let jg = false; let jg = false;
if (cc.fx.GameConfig.GM_INFO.level > 1299) { if (cc.fx.GameConfig.GM_INFO.level > 1199) {
cc.fx.GameConfig.GM_INFO.level = 1300; cc.fx.GameConfig.GM_INFO.level = 1200;
jg = true; jg = true;
} }
return jg; return jg;
@ -2416,7 +2416,7 @@ var GameTool = {
const query = launchOptions.query; const query = launchOptions.query;
// 检测是否为推荐流直玩场景scene后四位是3041 // 检测是否为推荐流直玩场景scene后四位是3041
const isRecommendFeedLaunch = scene && typeof scene === 'string' && scene.slice(-4) === '3041'; const isRecommendFeedLaunch = scene && typeof scene === 'string' && (scene.slice(-4) === '3041');
if (isRecommendFeedLaunch) { if (isRecommendFeedLaunch) {
// 处理推荐流直玩参数 // 处理推荐流直玩参数
@ -2503,7 +2503,7 @@ var GameTool = {
const scene = launchOptions.scene; const scene = launchOptions.scene;
// 检测是否为推荐流直玩场景scene后四位是3041 // 检测是否为推荐流直玩场景scene后四位是3041
const isRecommendFeedLaunch = scene && typeof scene === 'string' && scene.slice(-4) === '3041'; const isRecommendFeedLaunch = scene && typeof scene === 'string' && (scene.slice(-4) === '3041');
if (isRecommendFeedLaunch) { if (isRecommendFeedLaunch) {
// 上报预启动数据 // 上报预启动数据

View File

@ -33,6 +33,16 @@ export default class GenieEffect extends cc.Component {
const node = this.node; const node = this.node;
const size = node.getContentSize(); const size = node.getContentSize();
// 检查是否包含滚动视图,临时禁用裁剪
const scrollView = node.getComponent(cc.ScrollView);
const maskComponents = node.getComponentsInChildren(cc.Mask);
const originalMaskEnabled = maskComponents.map(m => m.enabled);
// 临时禁用所有 Mask 组件
maskComponents.forEach(mask => {
mask.enabled = false;
});
// 创建 RenderTexture // 创建 RenderTexture
const renderTexture = new cc.RenderTexture(); const renderTexture = new cc.RenderTexture();
renderTexture.initWithSize(size.width, size.height); renderTexture.initWithSize(size.width, size.height);
@ -49,12 +59,25 @@ export default class GenieEffect extends cc.Component {
camera.zoomRatio = 1; camera.zoomRatio = 1;
camera.cullingMask = 0xffffffff; camera.cullingMask = 0xffffffff;
// 特别处理:如果节点包含滚动视图,调整渲染设置
if (scrollView) {
// 对于滚动视图,强制渲染所有内容
camera.cullingMask = 0xffffffff;
// 设置更清晰的渲染质量
camera.zoomRatio = 1.5;
}
// 渲染一帧 // 渲染一帧
camera.render(); camera.render();
// 销毁相机节点 // 销毁相机节点
cameraNode.destroy(); cameraNode.destroy();
// 恢复 Mask 组件状态
maskComponents.forEach((mask, index) => {
mask.enabled = originalMaskEnabled[index];
});
// 创建 SpriteFrame // 创建 SpriteFrame
const spriteFrame = new cc.SpriteFrame(renderTexture); const spriteFrame = new cc.SpriteFrame(renderTexture);
@ -82,6 +105,10 @@ export default class GenieEffect extends cc.Component {
const sprite = spriteNode.addComponent(cc.Sprite); const sprite = spriteNode.addComponent(cc.Sprite);
sprite.spriteFrame = spriteFrame; sprite.spriteFrame = spriteFrame;
// 设置混合模式为透明
sprite.srcBlendFactor = cc.macro.BlendFactor.SRC_ALPHA;
sprite.dstBlendFactor = cc.macro.BlendFactor.ONE_MINUS_SRC_ALPHA;
// 隐藏原节点 // 隐藏原节点
this.node.active = false; this.node.active = false;
@ -197,10 +224,11 @@ export default class GenieEffect extends cc.Component {
// 获取 Sprite 组件 // 获取 Sprite 组件
const sprite = captureNode.getComponent(cc.Sprite); const sprite = captureNode.getComponent(cc.Sprite);
// 计算起始位置(世界坐标) // 获取起始位置和目标位置(世界坐标)
const fromWorldPos = fromNode.convertToWorldSpaceAR(cc.v2(0, 0)); const fromWorldPos = fromNode.convertToWorldSpaceAR(cc.v2(0, 0));
const targetWorldPos = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
// 设置材质参数(从完全吸入状态开始) // 设置材质参数
const material = this.genieMaterial; const material = this.genieMaterial;
material.setProperty('u_targetPos', [fromWorldPos.x, fromWorldPos.y]); material.setProperty('u_targetPos', [fromWorldPos.x, fromWorldPos.y]);
material.setProperty('u_progress', 1); material.setProperty('u_progress', 1);
@ -210,86 +238,103 @@ export default class GenieEffect extends cc.Component {
// 应用材质 // 应用材质
sprite.setMaterial(0, material); sprite.setMaterial(0, material);
// 播放动画progress 从 1 到 0 // 播放动画 - 同时移动节点和更新 Shader
const animData = { progress: 1 }; const animData = { progress: 1 };
const startPos = captureNode.position;
const targetPos = captureNode.parent.convertToNodeSpaceAR(targetWorldPos);
cc.tween(animData) cc.tween(animData)
.to(this.duration, { progress: 0 }, { .to(this.duration, { progress: 0 }, {
easing: 'quadOut', easing: 'quadInOut',
onUpdate: (target, ratio) => { onUpdate: (target, ratio) => {
if (material && sprite) { if (material && sprite) {
material.setProperty('u_progress', animData.progress); material.setProperty('u_progress', animData.progress);
} }
// 同时移动捕获节点向目标点靠近
if (captureNode) {
const t = animData.progress;
// 使用缓动函数让移动更自然
const easeT = t * t * (3 - 2 * t); // smoothstep
captureNode.x = startPos.x + (targetPos.x - startPos.x) * easeT;
captureNode.y = startPos.y + (targetPos.y - startPos.y) * easeT;
}
} }
}) })
.call(() => { .call(() => {
this._isPlaying = false; this._isPlaying = false;
// 显示原节点
this.node.active = true;
// 销毁捕获节点 // 销毁捕获节点
if (captureNode) { if (captureNode) {
captureNode.destroy(); captureNode.destroy();
} }
// 显示原节点
this.node.active = true;
if (callback) callback(); if (callback) callback();
}) })
.start(); .start();
} }
/** /**
* Shader 使 * 使 Shader
*/ */
private playDefaultClose(targetNode: cc.Node, callback?: Function) { playDefaultClose(targetNode: cc.Node, callback?: Function) {
const startPos = this.node.position; const targetWorldPos = targetNode.convertToWorldSpaceAR(cc.v2(0, 0)); if (this._isPlaying) {
const targetLocalPos = this.node.parent.convertToNodeSpaceAR(targetWorldPos); console.warn('GenieEffect: 动画正在播放中');
return;
}
this._isPlaying = true;
// 获取起始位置和目标位置(世界坐标)
const startWorldPos = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
const targetWorldPos = targetNode.convertToWorldSpaceAR(cc.v2(0, 0));
// 播放缩放和移动动画
cc.tween(this.node) cc.tween(this.node)
.to(this.duration * 0.5, { .to(this.duration, {
position: cc.v3( scale: 0,
startPos.x + (targetLocalPos.x - startPos.x) * 0.5, position: new cc.Vec3(this.node.parent.convertToNodeSpaceAR(targetWorldPos).x, this.node.parent.convertToNodeSpaceAR(targetWorldPos).y, 0)
startPos.y + (targetLocalPos.y - startPos.y) * 0.5, }, {
0 easing: 'quadInOut'
), })
scale: 0.6
}, { easing: 'quadIn' })
.to(this.duration * 0.5, {
position: cc.v3(targetLocalPos.x, targetLocalPos.y, 0),
scale: 0.01,
opacity: 0
}, { easing: 'expoIn' })
.call(() => { .call(() => {
this._isPlaying = false;
this.node.active = false;
if (callback) callback(); if (callback) callback();
}) })
.start(); .start();
} }
/** /**
* Shader 使 * 使 Shader
*/ */
private playDefaultOpen(fromNode: cc.Node, callback?: Function) { playDefaultOpen(fromNode: cc.Node, callback?: Function) {
if (this._isPlaying) {
console.warn('GenieEffect: 动画正在播放中');
return;
}
this._isPlaying = true;
// 获取起始位置和目标位置(世界坐标)
const fromWorldPos = fromNode.convertToWorldSpaceAR(cc.v2(0, 0)); const fromWorldPos = fromNode.convertToWorldSpaceAR(cc.v2(0, 0));
const fromLocalPos = this.node.parent.convertToNodeSpaceAR(fromWorldPos); const targetWorldPos = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
const endPos = this.node.position;
this.node.scale = 0.01; // 设置初始状态
this.node.opacity = 0; this.node.scale = 0;
this.node.position = cc.v3(fromLocalPos.x, fromLocalPos.y, 0); const fromPos = this.node.parent.convertToNodeSpaceAR(fromWorldPos);
this.node.position = new cc.Vec3(fromPos.x, fromPos.y, 0);
this.node.active = true;
// 播放缩放和移动动画
cc.tween(this.node) cc.tween(this.node)
.to(this.duration * 0.5, { .to(this.duration, {
position: cc.v3(
fromLocalPos.x + (endPos.x - fromLocalPos.x) * 0.5,
fromLocalPos.y + (endPos.y - fromLocalPos.y) * 0.5,
0
),
scale: 0.6,
opacity: 128
}, { easing: 'quadOut' })
.to(this.duration * 0.5, {
position: endPos,
scale: 1, scale: 1,
opacity: 255 position: new cc.Vec3(this.node.parent.convertToNodeSpaceAR(targetWorldPos).x, this.node.parent.convertToNodeSpaceAR(targetWorldPos).y, 0)
}, { easing: 'expoOut' }) }, {
easing: 'quadInOut'
})
.call(() => { .call(() => {
this._isPlaying = false;
if (callback) callback(); if (callback) callback();
}) })
.start(); .start();
@ -297,70 +342,33 @@ export default class GenieEffect extends cc.Component {
} }
/** /**
* - 便 * GenieEffect
* 便
*/ */
export namespace GenieEffectUtil { export class GenieEffectUtil {
/** /**
* *
* @param node * @param node
* @param targetNode * @param targetNode
* @param callback * @param callback
* @param material * @param material
* @param duration
*/ */
export function playClose( static playClose(node: cc.Node, targetNode: cc.Node, callback?: Function, material?: cc.Material) {
node: cc.Node, const genieEffect = node.addComponent(GenieEffect);
targetNode: cc.Node, genieEffect.genieMaterial = material;
callback?: Function, genieEffect.playClose(targetNode, callback);
material?: cc.Material,
duration: number = 0.4
) {
const genieEffect = node.getComponent(GenieEffect);
if (genieEffect) {
genieEffect.playClose(targetNode, callback);
} else {
// 动态添加组件并播放
const effect = node.addComponent(GenieEffect);
effect.duration = duration;
if (material) {
effect.genieMaterial = material;
}
// 延迟一帧等待组件初始化
cc.director.once(cc.Director.EVENT_AFTER_UPDATE, () => {
effect.playClose(targetNode, callback);
});
}
} }
/** /**
* *
* @param node * @param node
* @param fromNode * @param fromNode
* @param callback * @param callback
* @param material * @param material
* @param duration
*/ */
export function playOpen( static playOpen(node: cc.Node, fromNode: cc.Node, callback?: Function, material?: cc.Material) {
node: cc.Node, const genieEffect = node.addComponent(GenieEffect);
fromNode: cc.Node, genieEffect.genieMaterial = material;
callback?: Function, genieEffect.playOpen(fromNode, callback);
material?: cc.Material,
duration: number = 0.4
) {
const genieEffect = node.getComponent(GenieEffect);
if (genieEffect) {
genieEffect.playOpen(fromNode, callback);
} else {
const effect = node.addComponent(GenieEffect);
effect.duration = duration;
if (material) {
effect.genieMaterial = material;
}
cc.director.once(cc.Director.EVENT_AFTER_UPDATE, () => {
effect.playOpen(fromNode, callback);
});
}
} }
} }

View File

@ -8752,7 +8752,6 @@
"buyActivate": { "buyActivate": {
"__uuid__": "f0fbe7be-4949-478f-a6f5-06e86e7ffbdc" "__uuid__": "f0fbe7be-4949-478f-a6f5-06e86e7ffbdc"
}, },
"btnActivate1": null,
"genieMaterial": { "genieMaterial": {
"__uuid__": "d53fa0ca-8b03-4458-8359-c0b3d5fd3821" "__uuid__": "d53fa0ca-8b03-4458-8359-c0b3d5fd3821"
}, },