From 08c6106c35b2469201b164c2f9af427db39c7813 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 9 Oct 2014 02:30:31 +0100 Subject: [PATCH] Fixed issue with textureLine creating white blocks in iOS. --- src/core/FlexGrid.js | 4 ++-- src/gameobjects/BitmapData.js | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/core/FlexGrid.js b/src/core/FlexGrid.js index 4971846f9..e206f1350 100644 --- a/src/core/FlexGrid.js +++ b/src/core/FlexGrid.js @@ -314,8 +314,8 @@ Phaser.FlexGrid.prototype = { this.game.debug.text(this.boundsFluid.width + ' x ' + this.boundsFluid.height, this.boundsFluid.x + 4, this.boundsFluid.y + 16); this.game.debug.geom(this.boundsFluid, 'rgba(255,0,0,0.9', false); - this.game.debug.text(this.boundsNone.width + ' x ' + this.boundsNone.height, this.boundsNone.x + 4, this.boundsNone.y + 16); - this.game.debug.geom(this.boundsNone, 'rgba(0,255,0,0.9', false); + // this.game.debug.text(this.boundsNone.width + ' x ' + this.boundsNone.height, this.boundsNone.x + 4, this.boundsNone.y + 16); + // this.game.debug.geom(this.boundsNone, 'rgba(0,255,0,0.9', false); // this.game.debug.text(this.boundsCustom.width + ' x ' + this.boundsCustom.height, this.boundsCustom.x + 4, this.boundsCustom.y + 16); // this.game.debug.geom(this.boundsCustom, 'rgba(255,255,0,0.9', false); diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index 99e323b2b..5949c55fe 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -1248,15 +1248,30 @@ Phaser.BitmapData.prototype = { * * @method Phaser.BitmapData#textureLine * @param {Phaser.Line} line - A Phaser.Line object that will be used to plot the start and end of the line. - * @param {string} key - The key of an image in the Phaser.Cache to use as the texture for this line. + * @param {string|HTMLImage} image - The key of an image in the Phaser.Cache to use as the texture for this line, or an actual Image. * @param {string} [repeat='repeat-x'] - The pattern repeat mode to use when drawing the line. Either `repeat`, `repeat-x` or `no-repeat`. * @return {Phaser.BitmapData} This BitmapData object for method chaining. */ - textureLine: function (line, key, repeat) { + textureLine: function (line, image, repeat) { if (typeof repeat === 'undefined') { repeat = 'repeat-x'; } - var image = this.game.cache.getImage(key); + if (typeof image === 'string') + { + image = this.game.cache.getImage(image); + + if (!image) + { + return; + } + } + + var width = line.length; + + if (repeat === 'no-repeat' && width > image.width) + { + width = image.width; + } this.context.fillStyle = this.context.createPattern(image, repeat); @@ -1267,7 +1282,7 @@ Phaser.BitmapData.prototype = { this.context.save(); this.context.translate(this._pos.x, this._pos.y); this.context.rotate(line.angle); - this.context.fillRect(0, 0, line.length, image.height); + this.context.fillRect(0, 0, width, image.height); this.context.restore(); this.dirty = true;