Jump to content

A good way to set scene stop when hidden and run while visible again !

Andrew Chen

Recommended Posts


1.可以彻底让scene场景彻底休眠  make 100% sure the scene is sleeping 
2.update function不会再运行 .      the update function will not execute any more
3.同时会暂停场景内的Timer事件 t the timer is paused also

// phaser version 3.15.0

// GameScene
// 监听是否当前场景不可见/最小化 when scene is hide
        this.sys.game.events.on('hidden', function () {
            console.log('pause spawn bomb while hidden');
            console.log('gamescene is sleeping?', this.scene.isSleeping('GameScene'));

        }, this);

// 回到当前场景  back to current scene
        this.sys.game.events.on('visible', function () {
            console.log('spawn bomb while visible');
            console.log('gamescene is wake again:', this.scene.isSleeping());
        }, this);


www.iFIERO.com -- be proud of developing games

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...