抖音小游戏上线有倒计时类的程序,如果弹出了窗口,要求暂停倒计时,窗口关闭后继续倒计时。所以Panel
管理器需要抛出窗口显示
和隐藏
这两个事件。
编辑framework/scripts/AppConstants.ts
,添加PanelShow
和PanelHide
定义。
// Panel 遮罩类型
public static readonly panelMaskStyle = {
// 不可穿透
NoThrough: 0b1,
// 半透明
Black: 0b10,
// 关闭组件
Close: 0b100,
}
// 事件
public static readonly event = {
PanelShow: 'PanelShow',
PanelHide: 'PanelHide',
}
编辑framework/scripts/manager/EventMgr.ts
,修改emit
方法过滤PanelShow
和PanelHide
未注册事件日志输出(因为有的平台不需要监听这两个事件)。
public static emit(event: string, ...params: any[]) {
if (!this._events.has(event)) {
if (event != AppConstants.event.PanelShow && event != AppConstants.event.PanelHide) {
console.error('EventMgr.emit event:' + event + ' 未注册')
}
return
}
this._events.get(event).forEach(({ cb, ctx }) => {
cb.apply(ctx, params)
})
}
编辑framework/scripts/view/PanelMgr.ts
,修改hideAll
方法。
public static hideAll() {
this._panels.forEach(panel => {
if (panel.skin.active) {
this.destroy(panel.panelName)
}
})
EventMgr.emit(AppConstants.event.PanelHide)
}
修改showPanelAfter2
方法。
private static showPanelAfter2(isOpen: boolean) {
TopBlock.hide()
if (isOpen) {
EventMgr.emit(AppConstants.event.PanelShow)
} else {
let hide = true
this._panels.forEach(panel => {
if (panel.skin.active) hide = false
})
hide && EventMgr.emit(AppConstants.event.PanelHide)
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。