zoukankan      html  css  js  c++  java
  • PHASER3 设置场景SCENE SLEEPING休眠和WAKE唤醒

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

    使用sleep和wake方法的好处:

    1.可以彻底让scene场景彻底休眠
    2.update function不会再运行
    3.同时会暂停场景内的Timer事件

    GameScene.js代码

    // phaser version 3.15.0
    // 监听是否当前场景不可见/最小化
            this.sys.game.events.on('hidden', function () {
                console.log('pause spawn bomb while hidden');
                console.log('gamescene is sleeping?', this.scene.isSleeping('GameScene'));
                console.groupEnd();
                game.scene.keys['GameScene'].sys.sleep();
    
            }, this);
    
    // 回到当前场景
            this.sys.game.events.on('visible', function () {
                console.log('spawn bomb while visible');
                console.groupEnd();
                console.log('gamescene is wake again:', this.scene.isSleeping());
                game.scene.keys['GameScene'].sys.wake();
                this.createCheckNetWork();
            }, this);
    

    更多游戏教程:www.iFIERO.com – 为游戏开发深感自豪

  • 相关阅读:
    2019 SDN阅读作业
    第10组 Alpha冲刺(4/6)
    第10组 Alpha冲刺(3/6)
    2019 SDN上机第3次作业
    团队Beta4
    团队Beta3
    团队Beta2
    团队Beta1
    tuandui last
    团队Arpha6
  • 原文地址:https://www.cnblogs.com/apiapia/p/9990539.html
Copyright © 2011-2022 走看看