Skip to content

Commit 077d533

Browse files
committed
BitmapMask would become corrupted when resizing the Phaser Game, either via the Scale Manager or directly, because the framebuffer and texture it used for rendering was still at the old dimensions. The BitmapMask now listens for the Renderer RESIZE event and re-creates itself accordingly. Fix phaserjs#5399
1 parent 38b6d83 commit 077d533

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/display/mask/BitmapMask.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
var Class = require('../../utils/Class');
88
var GameEvents = require('../../core/events');
9+
var RenderEvents = require('../../renderer/webgl/events');
910

1011
/**
1112
* @classdesc
@@ -72,7 +73,7 @@ var BitmapMask = new Class({
7273
this.bitmapMask = renderable;
7374

7475
/**
75-
* The texture used for the mask's framebuffer.
76+
* The texture used for the masks framebuffer.
7677
*
7778
* @name Phaser.Display.Masks.BitmapMask#maskTexture
7879
* @type {WebGLTexture}
@@ -144,6 +145,8 @@ var BitmapMask = new Class({
144145
this.createMask();
145146

146147
scene.sys.game.events.on(GameEvents.CONTEXT_RESTORED, this.createMask, this);
148+
149+
renderer.on(RenderEvents.RESIZE, this.createMask, this);
147150
},
148151

149152
/**
@@ -296,6 +299,8 @@ var BitmapMask = new Class({
296299
{
297300
this.clearMask();
298301

302+
this.renderer.off(RenderEvents.RESIZE, this.createMask, this);
303+
299304
this.bitmapMask = null;
300305
this.prevFramebuffer = null;
301306
this.renderer = null;

0 commit comments

Comments
 (0)