Skip to content

Commit 04689f0

Browse files
committed
Fixes 1707 - BaseTexture defaults to resolution of 1
Recreating after move to CE.
1 parent 14d2c6a commit 04689f0

5 files changed

Lines changed: 17 additions & 13 deletions

File tree

v2-community/src/gameobjects/BitmapData.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Phaser.BitmapData = function (game, key, width, height, skipPool) {
121121
* @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture.
122122
* @default
123123
*/
124-
this.baseTexture = new PIXI.BaseTexture(this.canvas);
124+
this.baseTexture = new PIXI.BaseTexture(this.canvas, null, this.game.resolution);
125125

126126
/**
127127
* @property {PIXI.Texture} texture - The PIXI.Texture.

v2-community/src/gameobjects/Video.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ Phaser.Video = function (game, key, url) {
254254
*/
255255
if (this.video && !url)
256256
{
257-
this.baseTexture = new PIXI.BaseTexture(this.video);
257+
this.baseTexture = new PIXI.BaseTexture(this.video, null, this.game.resolution);
258258
this.baseTexture.forceLoaded(this.width, this.height);
259259
}
260260
else
261261
{
262-
this.baseTexture = new PIXI.BaseTexture(Phaser.Cache.DEFAULT.baseTexture.source);
262+
this.baseTexture = new PIXI.BaseTexture(Phaser.Cache.DEFAULT.baseTexture.source, null, this.game.resolution);
263263
this.baseTexture.forceLoaded(this.width, this.height);
264264
}
265265

v2-community/src/loader/Cache.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Phaser.Cache.prototype = {
252252
key: key,
253253
url: url,
254254
data: data,
255-
base: new PIXI.BaseTexture(data),
255+
base: new PIXI.BaseTexture(data, null, this.game.resolution),
256256
frame: new Phaser.Frame(0, 0, 0, data.width, data.height, key),
257257
frameData: new Phaser.FrameData(),
258258
fileFormat: extension
@@ -305,7 +305,7 @@ Phaser.Cache.prototype = {
305305
key: key,
306306
url: url,
307307
data: data,
308-
base: new PIXI.BaseTexture(data),
308+
base: new PIXI.BaseTexture(data, null, this.game.resolution),
309309
frame: new Phaser.Frame(0, 0, 0, data.width, data.height, key),
310310
frameData: new Phaser.FrameData()
311311
};
@@ -518,7 +518,7 @@ Phaser.Cache.prototype = {
518518
url: url,
519519
data: data,
520520
font: null,
521-
base: new PIXI.BaseTexture(data)
521+
base: new PIXI.BaseTexture(data, null, this.game.resolution)
522522
};
523523

524524
if (xSpacing === undefined) { xSpacing = 0; }
@@ -700,7 +700,7 @@ Phaser.Cache.prototype = {
700700
frameHeight: frameHeight,
701701
margin: margin,
702702
spacing: spacing,
703-
base: new PIXI.BaseTexture(data),
703+
base: new PIXI.BaseTexture(data, null, this.game.resolution),
704704
frameData: Phaser.AnimationParser.spriteSheet(this.game, data, frameWidth, frameHeight, frameMax, margin, spacing, skipFrames)
705705
};
706706

@@ -726,7 +726,7 @@ Phaser.Cache.prototype = {
726726
key: key,
727727
url: url,
728728
data: data,
729-
base: new PIXI.BaseTexture(data)
729+
base: new PIXI.BaseTexture(data, null, this.game.resolution)
730730
};
731731

732732
if (format === Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)

v2-community/src/pixi/textures/BaseTexture.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
* @constructor
1111
* @param source {String|Canvas} the source object (image or canvas)
1212
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
13+
* @param [resolution] {Number} the resolution of the texture (for HiDPI displays)
1314
*/
14-
PIXI.BaseTexture = function(source, scaleMode)
15+
PIXI.BaseTexture = function(source, scaleMode, resolution)
1516
{
1617
/**
1718
* The Resolution of the texture.
1819
*
1920
* @property resolution
2021
* @type Number
2122
*/
22-
this.resolution = 1;
23+
this.resolution = resolution || 1;
2324

2425
/**
2526
* [read-only] The width of the base texture set when the image has loaded
@@ -235,9 +236,10 @@ PIXI.BaseTexture.prototype.unloadFromGPU = function()
235236
* @method fromCanvas
236237
* @param canvas {Canvas} The canvas element source of the texture
237238
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
239+
* @param [resolution] {Number} the resolution of the texture (for HiDPI displays)
238240
* @return {BaseTexture}
239241
*/
240-
PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
242+
PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode, resolution)
241243
{
242244
if (canvas.width === 0)
243245
{
@@ -249,5 +251,7 @@ PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
249251
canvas.height = 1;
250252
}
251253

252-
return new PIXI.BaseTexture(canvas, scaleMode);
254+
resolution = resolution || 1;
255+
256+
return new PIXI.BaseTexture(canvas, scaleMode, resolution);
253257
};

v2-community/src/tilemap/TilemapLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
6565
*/
6666
this.context = this.canvas.getContext('2d');
6767

68-
this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas)));
68+
this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas, null, this.game.resolution)));
6969

7070
/**
7171
* The const type of this object.

0 commit comments

Comments
 (0)