mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
The Game boot event flow has changed slightly. The Game will now listen for a texturesready
event, which is dispatched by the Texture Manager when the default textures have finished processing. Upon receiving this, the Game will emit the ready
event, which all the other systems listen for and respond to. The difference is that the Renderer uses the texturesready
event to ensure that it is the first thing to be activated, before any other system.
This commit is contained in:
parent
94e4411ac1
commit
73524df816
4 changed files with 33 additions and 6 deletions
|
@ -68,6 +68,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
|
|||
* The `MouseManager` will no longer process its native events if the manager reference has been removed (i.e. you move the pointer as the game is destroying itself)
|
||||
* The `TouchManager` will no longer process its native events if the manager reference has been removed (i.e. you move the pointer as the game is destroying itself)
|
||||
* `Particle.color` has been removed as it's now calculated during rendering to allow for Camera alpha support.
|
||||
* The Game boot event flow has changed slightly. The Game will now listen for a `texturesready` event, which is dispatched by the Texture Manager when the default textures have finished processing. Upon receiving this, the Game will emit the `ready` event, which all the other systems listen for and respond to. The difference is that the Renderer uses the `texturesready` event to ensure that it is the first thing to be activated, before any other system.
|
||||
|
||||
### Game Config Resolution Specific Bug Fixes
|
||||
|
||||
|
|
|
@ -356,8 +356,26 @@ var Game = new Class({
|
|||
|
||||
this.events.emit('boot');
|
||||
|
||||
// The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event
|
||||
this.events.once('ready', this.start, this);
|
||||
// The Texture Manager has to wait on a couple of non-blocking events before it's fully ready.
|
||||
// So it will emit this internal event when done:
|
||||
this.events.once('texturesready', this.texturesReady, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called automatically when the Texture Manager has finished setting up and preparing the
|
||||
* default textures.
|
||||
*
|
||||
* @method Phaser.Game#texturesReady
|
||||
* @private
|
||||
* @fires Phaser.Game#ready
|
||||
* @since 3.12.0
|
||||
*/
|
||||
texturesReady: function ()
|
||||
{
|
||||
// Start all the other systems
|
||||
this.events.emit('ready');
|
||||
|
||||
this.start();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -520,7 +520,7 @@ var WebGLRenderer = new Class({
|
|||
|
||||
this.resize(this.width, this.height);
|
||||
|
||||
this.game.events.once('ready', this.boot, this);
|
||||
this.game.events.once('texturesready', this.boot, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -544,6 +544,8 @@ var WebGLRenderer = new Class({
|
|||
this.pipelines.TextureTintPipeline.currentFrame = blank;
|
||||
|
||||
this.blankTexture = blank;
|
||||
|
||||
console.log('renderer boot', this.pipelines.TextureTintPipeline.currentFrame);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -965,12 +967,16 @@ var WebGLRenderer = new Class({
|
|||
* @method Phaser.Renderer.WebGL.WebGLRenderer#setBlankTexture
|
||||
* @private
|
||||
* @since 3.12.0
|
||||
*
|
||||
* @param {boolean} [force=false] - Force a blank texture set, regardless of what's already bound?
|
||||
*
|
||||
* @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer.
|
||||
*/
|
||||
setBlankTexture: function ()
|
||||
setBlankTexture: function (force)
|
||||
{
|
||||
if (this.currentActiveTextureUnit !== 0 || !this.currentTextures[0])
|
||||
if (force === undefined) { force = false; }
|
||||
|
||||
if (force || this.currentActiveTextureUnit !== 0 || !this.currentTextures[0])
|
||||
{
|
||||
this.setTexture2D(this.blankTexture.glTexture, 0);
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ var TextureManager = new Class({
|
|||
* The Boot Handler called by Phaser.Game when it first starts up.
|
||||
*
|
||||
* @method Phaser.Textures.TextureManager#boot
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
|
@ -135,6 +136,7 @@ var TextureManager = new Class({
|
|||
* After 'onload' or 'onerror' invoked twice, emit 'ready' event.
|
||||
*
|
||||
* @method Phaser.Textures.TextureManager#updatePending
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
updatePending: function ()
|
||||
|
@ -146,7 +148,7 @@ var TextureManager = new Class({
|
|||
this.off('onload');
|
||||
this.off('onerror');
|
||||
|
||||
this.game.events.emit('ready');
|
||||
this.game.events.emit('texturesready');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue