Jump to content

phaser-spine no way to pause the plugin?


farhan
 Share

Recommended Posts

I am using phaser-spine for my Phaser 2 project, main issue is the spine is not pause when the game is pause/out of focus etc

Is there a way for the plugin to automatically pause when the game is paused? 

Currently the only way to pause is by doing this

spine.state.timeScale = 0.0; onBlur/Pause and set to 1.0 onFocus

but if I have 100 spines, it would have to manually set this to all of them

I see the globalAutoUpdate, doesn't work, makes no difference. Unless I am calling it incorrectly?

I did PhaserSpine.globalAutoUpdate = false to pause but no changes.

Anyone got any tips or at least a point me to the right code that I can modify or add something to make the whole plugin pause when Phaser is pause or out of focus, via versa. Thanks!

Link to comment
Share on other sites

I guess I have fixed it, you have to call PhaserSpine.Spine.globalAutoUpdate = false; then it works
But to make it easier I just modify phaser-spine plugin and just add in its constructor

            _this.game.onPause.add(_this.onPause, _this);
            _this.game.onResume.add(_this.onResume, _this);
            _this.game.onPause.add(_this.onBlur, _this);
            _this.game.onResume.add(_this.onFocus, _this);

and the functions 

        Spine.prototype.onPause = function () {
            Spine.globalAutoUpdate = false;
        };
        Spine.prototype.onResume = function () {
            Spine.globalAutoUpdate = true;
        };
        Spine.prototype.onBlur = function () {
            Spine.globalAutoUpdate = false;
        };
        Spine.prototype.onFocus = function () {
            Spine.globalAutoUpdate = true;
        };

Now, it will pause all spines in game without needing to add anything on game side :D 

I recommend to have this is phaser-spine plugin, unless there is a reason these are not in the plugin in the first place.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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