Problem With Pausing The Game

Hi Everyone ! …
So in my game when the battle is going on and i press on the “pause” button the pase
menu opens and the game pauses until i click on resume … but i am facing a problem
when i use either browser or simulator and minimize the window or go to another tab and go back to the game the game automatically resumes even though the pause menu is still open … i hope someone can help me with this ! Thanks
this is the code for pausing :
waitBtn() { // pause button

    let all = cc.find("Canvas");

    let button = cc.find("Canvas/AllBtn/WaitBtn")

    //Resume all touch click events

    //Delayed execution pause

    this.scheduleOnce(function() {

        all.pauseSystemEvents(true); //Pause all touch click events = true


        // Increased  zIndex Property To Menu

        this.Menu.zIndex = 100;

    }, 0.15);

    button.interactable = false

},, function () {
      // do something

this event triggered when game back to foreground,you can re-pause in the callback

1 Like

Thank you ! i will try it