Skip to content

Commit a1f618f

Browse files
committed
Debugging tileset issue.
1 parent f57d3c1 commit a1f618f

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/tilemap/TilemapLayer.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,23 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
7070
* @property {PIXI.BaseTexture} baseTexture
7171
* @protected
7272
*/
73-
this.baseTexture = new PIXI.BaseTexture(this.canvas);
73+
// this.baseTexture = new PIXI.BaseTexture(this.canvas);
7474

7575
/**
7676
* Required Pixi var.
7777
* @property {PIXI.Texture} texture
7878
* @protected
7979
*/
80-
this.texture = new PIXI.Texture(this.baseTexture);
80+
// this.texture = new PIXI.Texture(this.baseTexture);
8181

8282
/**
8383
* Dimensions of the renderable area.
8484
* @property {Phaser.Frame} textureFrame
8585
* @protected
8686
*/
87-
this.textureFrame = new Phaser.Frame(0, 0, 0, width, height, 'tilemapLayer');
87+
// this.textureFrame = new Phaser.Frame(0, 0, 0, width, height, 'tilemapLayer');
88+
89+
this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas)));
8890

8991
/**
9092
* The const type of this object.
@@ -104,7 +106,7 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
104106
/**
105107
* Settings that control standard (non-diagnostic) rendering.
106108
*
107-
* @property {boolean} [enableScrollDelta=true] - Delta scroll rendering only draws tiles/edges as them come into view.
109+
* @property {boolean} [enableScrollDelta=true] - Delta scroll rendering only draws tiles/edges as they come into view.
108110
* This can greatly improve scrolling rendering performance, especially when there are many small tiles.
109111
* It should only be disabled in rare cases.
110112
*
@@ -331,13 +333,12 @@ Phaser.TilemapLayer.prototype.postUpdate = function () {
331333
*/
332334
Phaser.TilemapLayer.resize = function (width, height) {
333335

334-
this.baseTexture.width = width;
335-
this.baseTexture.height = height;
336+
// this.baseTexture.width = width;
337+
// this.baseTexture.height = height;
336338

337339
this.resizeFrame(width, height);
338340

339-
this.textureFrame.resize(width, height);
340-
341+
// this.textureFrame.resize(width, height);
341342

342343
};
343344

@@ -1064,7 +1065,7 @@ Phaser.TilemapLayer.prototype.render = function () {
10641065
this.renderDebug();
10651066
}
10661067

1067-
this.baseTexture.dirty();
1068+
this.texture.baseTexture.dirty();
10681069

10691070
this.dirty = false;
10701071

src/tilemap/Tileset.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Phaser.Tileset.prototype = {
177177
*/
178178
setImage: function (image) {
179179

180+
console.log('Tileset.setImage', image.width, image.height);
180181
this.image = image;
181182
this.updateTileData(image.width, image.height);
182183

@@ -187,8 +188,8 @@ Phaser.Tileset.prototype = {
187188
*
188189
* @method Phaser.Tileset#setSpacing
189190
* @public
190-
* @param {integer} tileMargin - The margin around the tiles in the sheet (in pixels).
191-
* @param {integer} tileSpacing - The spacing between the tiles in the sheet (in pixels).
191+
* @param {integer} [margin=0] - The margin around the tiles in the sheet (in pixels).
192+
* @param {integer} [spacing=0] - The spacing between the tiles in the sheet (in pixels).
192193
*/
193194
setSpacing: function (margin, spacing) {
194195

@@ -216,6 +217,9 @@ Phaser.Tileset.prototype = {
216217
var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing);
217218
var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing);
218219

220+
console.log(imageWidth, imageHeight, rowCount, colCount);
221+
console.log('ts', this.tileMargin, this.tileSpacing, 'th', this.tileWidth, this.tileHeight);
222+
219223
if (rowCount % 1 !== 0 || colCount % 1 !== 0)
220224
{
221225
console.warn("Phaser.Tileset - image tile area is not an even multiple of tile size");

0 commit comments

Comments
 (0)