网页切换到后台暂停游戏

This commit is contained in:
2025-06-04 16:17:58 +08:00
parent 81f0bdcdaa
commit d754066a88
2 changed files with 10 additions and 3 deletions

View File

@@ -143,6 +143,16 @@ export class Stage extends Laya.Script {
this.btn_hint_ad = this.btn_hint.getChildByName("Image").getChildByName("ad") as Laya.Box
this.btn_hint_label = this.btn_hint.getChildByName("Image").getChildByName("normal").getChildByName("label") as Laya.Label
//失去舞台焦点(切出游戏)的处理
Laya.stage.on(Laya.Event.BLUR, this, () => {
Stage.EventUpdatePause(true)
})
//获得舞台焦点(切回游戏)的处理
Laya.stage.on(Laya.Event.FOCUS, this, () => {
Stage.EventUpdatePause(false)
})
EventManager.getInstance().RegisterEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE, Stage.EventUpdateMistake)
EventManager.getInstance().RegisterEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, Stage.EventUpdatePause)
}

View File

@@ -12,7 +12,6 @@ const { regClass, property } = Laya
export class DailyChallenge extends Laya.Script {
declare owner: Laya.Box
@property(Laya.Sprite)
public sprite_bottom: Laya.Sprite
@@ -306,7 +305,5 @@ export class DailyChallenge extends Laya.Script {
UIManager.getInstance().loadTrophyClaimUI(find)
user.set_trophyNew(find, false)
}
}
}