Sign in to follow this  
farhan

phaser-spine no way to pause the plugin?

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!

Share this post


Link to post
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.

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.