perf: 支持通知
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Component, Node, Vec3, input, Input, EventTouch, Camera, view, tween, Animation, Collider2D, BoxCollider2D, Contact2DType, Label, Color, Canvas, UITransform, AudioSource, director, PhysicsSystem2D, EPhysics2DDrawFlags } from 'cc';
|
||||
import { _decorator, Component, Node, Vec3, input, Input, EventTouch, Camera, view, tween, Animation, Collider2D, BoxCollider2D, Contact2DType, Label, Color, Canvas, UITransform, AudioSource, director, PhysicsSystem2D, EPhysics2DDrawFlags, sys } from 'cc';
|
||||
import { TiledMapPathfinder } from './TiledMapPathfinder';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -1492,6 +1492,7 @@ export class PlayerController extends Component {
|
||||
*/
|
||||
public showBonusPopup() {
|
||||
this.showPopupAtCameraCenter(this.bonus, '奖励弹窗');
|
||||
this.setupEnterButtonListener();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1666,4 +1667,46 @@ export class PlayerController extends Component {
|
||||
director.loadScene(sceneName);
|
||||
}, 0.3); // 延迟0.3秒,让弹窗消失动画完成
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Enter按钮监听器
|
||||
*/
|
||||
private setupEnterButtonListener() {
|
||||
if (!this.bonus) {
|
||||
console.warn('奖励弹窗节点未设置,无法监听Enter按钮');
|
||||
return;
|
||||
}
|
||||
|
||||
// 查找Enter按钮节点
|
||||
const enterButton = this.bonus.getChildByName('Enter');
|
||||
if (!enterButton) {
|
||||
console.warn('未找到Enter按钮节点');
|
||||
return;
|
||||
}
|
||||
|
||||
// 移除之前的监听器(如果存在)
|
||||
enterButton.off(Node.EventType.TOUCH_END, this.onEnterButtonClick, this);
|
||||
|
||||
// 添加新的监听器
|
||||
enterButton.on(Node.EventType.TOUCH_END, this.onEnterButtonClick, this);
|
||||
console.log('已设置Enter按钮监听器');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter按钮点击事件处理
|
||||
*/
|
||||
private onEnterButtonClick() {
|
||||
console.log('Enter按钮被点击,执行微信小游戏状态通知');
|
||||
|
||||
// 隐藏奖励弹窗
|
||||
if (this.bonus) {
|
||||
this.hidePopupWithAnimation(this.bonus, '奖励弹窗');
|
||||
}
|
||||
|
||||
// 执行微信小游戏状态通知代码
|
||||
if (sys.platform === sys.Platform.WECHAT_GAME && (window as any).wx?.notifyMiniProgramPlayableStatus) {
|
||||
(window as any).wx.notifyMiniProgramPlayableStatus({ isEnd: true });
|
||||
console.log('已发送微信小游戏结束状态通知');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user