更新首页homeScene涉及到的按钮,以及涉及到的所有分包或者活动的按钮 增加震动

This commit is contained in:
COMPUTER\EDY
2026-09-22 17:38:43 +08:00
parent b028946207
commit 2e0d1826f1
12 changed files with 229 additions and 10 deletions
+10
View File
@@ -20,6 +20,7 @@ import { initProvinceLocator } from "./module/Position/GetPosition";
import LoadingCatAnimation from "./LoadingCatAnimation";
import BlockAssetManager from "./module/Tool/BlockAssetManager";
import MiniProgramBenefitsBridge from "./module/MiniProgramBenefitsBridge";
import { onHomeButtonTouchEnd, vibrateHomeButton } from "./module/Tool/HomeButtonVibration";
const { ccclass, property } = cc._decorator;
@ccclass
@@ -46,6 +47,7 @@ export default class JiaZai extends cc.Component {
}
// 新的主动操作取代尚未打开的按需弹窗;资源下载仍正常完成并写入缓存。
this.homePopupOpenRequest++;
if (vibrateHomeButton(event)) return;
try {
cc.fx.GameTool.setVibrate("light", 1);
} catch (error) {
@@ -366,6 +368,14 @@ export default class JiaZai extends cc.Component {
MiniGameSdk.API.showToast("当前设备内存不足,排行榜暂不可用");
}
onEnable() {
this.node.on(cc.Node.EventType.TOUCH_END, onHomeButtonTouchEnd, this, true);
}
onDisable() {
this.node.off(cc.Node.EventType.TOUCH_END, onHomeButtonTouchEnd, this, true);
}
onLoad() {
// 首页在进关前展示连胜;覆盖登录或缓存恢复的测试初始值。
if (cc.fx.GameConfig.forceOldRainbowWinStreakC || cc.fx.GameConfig.forceRainbowWinStreakB) {
+1 -1
View File
@@ -1022,7 +1022,7 @@ export default class MapConroler extends cc.Component {
const hand = child.getChildByName('hand');
if (!hand) return;
const animation = hand.getComponent(GuideHand) || hand.addComponent(GuideHand);
animation.rippleMaterial = rippleSprite.sharedMaterials[0];
animation.rippleMaterial = rippleSprite.getMaterial(0);
});
this.propGuideMask = guide;
guide.parent = this.node.parent;
@@ -1,5 +1,6 @@
import LoadingCatAnimation from "../LoadingCatAnimation";
import SevenDayGiftBootstrapApi from "../seven_day_gift/SevenDayGiftBootstrapApi";
import { vibrateHomeButton } from "./Tool/HomeButtonVibration";
declare const wx: any;
@@ -18,7 +19,7 @@ export default class MiniProgramBenefitsBridge {
private entryRed: cc.Node = null;
private entryFrame: cc.SpriteFrame = null;
private entryVisual: cc.Node = null;
private onEntryTouch = (): void => { this.open(); };
private onEntryTouch = (event: cc.Event): void => { vibrateHomeButton(event); this.open(); };
private session: any = null;
private rewardRequests = 0;
private testMount = 0;
@@ -0,0 +1,34 @@
const handledEvents = new WeakSet<cc.Event>();
/** 返回是否由首页统一处理;旧入口在其他场景仍可保留原有行为。 */
export function vibrateHomeButton(event?: cc.Event): boolean {
if (!event) return false;
const scene = cc.director.getScene();
if (!scene || scene.name !== "HomeScene") return false;
if (handledEvents.has(event)) return true;
handledEvents.add(event);
try {
cc.fx.GameTool.setVibrate("light", 1);
} catch (error) {
console.warn("HomeScene 按钮轻振动调用失败:", error);
}
return true;
}
/** 根节点捕获触摸,自动覆盖后来挂入首页的 Bundle 按钮。 */
export function onHomeButtonTouchEnd(event: cc.Event.EventTouch): void {
// 引擎可能复用事件对象,每次派发重新去重。
handledEvents.delete(event);
let target = event.target as cc.Node;
while (target) {
const button = target.getComponent(cc.Button);
if (button) {
if (button.interactable && button.enabledInHierarchy && (button as any)._pressed) {
vibrateHomeButton(event);
}
return;
}
if (target === event.currentTarget) return;
target = target.parent;
}
}
@@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "b9f1f6e3-d1e1-4a3d-a1a6-f3089fd502dd",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}