Jump to content

paused problem


Recommended Posts



Three days ago i kicked my own renderer and now rewriting my editor using Phaser. And still haven't regret the move.

In the editor I have a mode where I can create and place Sprites and set properties, define events etc. Then i can press play-button and preview the game in the editor.

So in the creation mode physics, movements, music and so on should be stopped and reset. So I thought that I can simply set this.game.paused = true but if i set the sprite velocity, the sprite starts to move even when paused. 


The question is: Is paused applied to properties like velocity?


Here are two old WIP videos of my editor I port now to Phaser. Actually wanted to use pixi.js, but Phaser covers even this!


(min 1.48. can Phaser render in extrernal canvas for spritesheet animation previews?)


I will probably have some more questions in the next time.





Link to comment
Share on other sites

This is the core Game update loop:

    /**    * The core game loop.    *    * @method Phaser.Game#update    * @protected    * @param {number} time - The current time as provided by RequestAnimationFrame.    */    update: function (time) {        this.time.update(time);        if (this._paused)        {            this.renderer.render(this.stage._stage);            this.plugins.render();            this.state.render();        }        else        {            this.plugins.preUpdate();            this.world.preUpdate();            this.stage.update();            this.input.update();            this.tweens.update();            this.sound.update();            this.state.update();            this.world.update();            this.particles.update();                        this.plugins.update();            this.world.postUpdate();            this.plugins.postUpdate();            if (this.renderType !== Phaser.HEADLESS)            {                this.renderer.render(this.stage._stage);                this.plugins.render();                this.state.render();                this.plugins.postRender();            }        }    },

As you can see only the render methods are called if the game is paused, so my guess would be that it wasn't actually paused - or some interaction un-paused it again? It could be the visibility check. I would disable that for a game editor: game.stage.disableVisibilityChange = true


But let me know if you find anything else that causes it!

Link to comment
Share on other sites

Thanks for a fast answer.


The problem is really strange. It actually pauses if I press the pause button and resumes by play. 

But the strange thing is that if I press somewhere on my editor and the game is in the pause state, then the game will be resume.


Here is an example. Click on the text to stop the sprite. If you click somewhere else the game will be resumed. But I never put game.paused=false anywhere. (except preload)

 game.stage.disableVisibilityChange = true doesn't help.



Link to comment
Share on other sites

Yes it's the issue we fixed in the dev branch. For now edit src/input/Pointer.js - specifically the start function. You need this bit:

        //  Fix to stop rogue browser plugins from blocking the visibility state event        if (this.game.stage.disableVisibilityChange === false && this.game.paused && this.game.stage.scale.incorrectOrientation === false)        {            this.game.paused = false;            return this;        }

Replace the current version with the one above and all should be fine (keep the disableVisibilityChange = true in your code though).

Link to comment
Share on other sites


  • Recently Browsing   0 members

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