Skip to content

Commit 82fb296

Browse files
committed
Code formatting issues.
1 parent 49fb798 commit 82fb296

2 files changed

Lines changed: 33 additions & 85 deletions

File tree

src/pixi/extras/Tilemap.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ PIXI.Tilemap.prototype._initWebGL = function (renderSession) {
132132

133133
};
134134

135-
136135
PIXI.Tilemap.prototype._renderBatch = function (renderSession) {
137136

138137
if (this.glBatch)

src/tilemap/TilemapLayerGL.js

Lines changed: 33 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* @author Richard Davey <rich@photonstorm.com>
3+
* @author Pete Baron <pete@photonstorm.com>
34
* @copyright 2016 Photon Storm Ltd.
45
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
56
*/
@@ -72,64 +73,19 @@ Phaser.TilemapLayerGL = function (game, tilemap, index, width, height) {
7273
/**
7374
* Settings that control standard (non-diagnostic) rendering.
7475
*
75-
* @property {boolean} [enableScrollDelta=true] - Delta scroll rendering only draws tiles/edges as they come into view.
76-
* This can greatly improve scrolling rendering performance, especially when there are many small tiles.
77-
* It should only be disabled in rare cases.
78-
*
79-
* @property {?DOMCanvasElement} [copyCanvas=(auto)] - [Internal] If set, force using a separate (shared) copy canvas.
80-
* Using a canvas bitblt/copy when the source and destinations region overlap produces unexpected behavior
81-
* in some browsers, notably Safari.
76+
* @property {float} [overdrawRatio=0.20] - Over Draw ratio.
8277
*
8378
* @default
8479
*/
8580
this.renderSettings = {
86-
enableScrollDelta: false,
87-
overdrawRatio: 0.20,
88-
copyCanvas: null
81+
overdrawRatio: 0.20
8982
};
9083

91-
/**
92-
* Enable an additional "debug rendering" pass to display collision information.
93-
*
94-
* @property {boolean} debug
95-
* @default
96-
*/
97-
this.debug = false;
98-
9984
/**
10085
* @property {boolean} exists - Controls if the core game loop and physics update this game object or not.
10186
*/
10287
this.exists = true;
10388

104-
/**
105-
* Settings used for debugging and diagnostics.
106-
*
107-
* @property {?string} missingImageFill - A tile is rendered as a rectangle using the following fill if a valid tileset/image cannot be found. A value of `null` prevents additional rendering for tiles without a valid tileset image. _This takes effect even when debug rendering for the layer is not enabled._
108-
*
109-
* @property {?string} debuggedTileOverfill - If a Tile has `Tile#debug` true then, after normal tile image rendering, a rectangle with the following fill is drawn above/over it. _This takes effect even when debug rendering for the layer is not enabled._
110-
*
111-
* @property {boolean} forceFullRedraw - When debug rendering (`debug` is true), and this option is enabled, the a full redraw is forced and rendering optimization is suppressed.
112-
*
113-
* @property {number} debugAlpha - When debug rendering (`debug` is true), the tileset is initially rendered with this alpha level. This can make the tile edges clearer.
114-
*
115-
* @property {?string} facingEdgeStroke - When debug rendering (`debug` is true), this color/stroke is used to draw "face" edges. A value of `null` disables coloring facing edges.
116-
*
117-
* @property {?string} collidingTileOverfill - When debug rendering (`debug` is true), this fill is used for tiles that are collidable. A value of `null` disables applying the additional overfill.
118-
*
119-
*/
120-
this.debugSettings = {
121-
122-
missingImageFill: 'rgb(255,255,255)',
123-
debuggedTileOverfill: 'rgba(0,255,0,0.4)',
124-
125-
forceFullRedraw: true,
126-
127-
debugAlpha: 0.5,
128-
facingEdgeStroke: 'rgba(0,255,0,1)',
129-
collidingTileOverfill: 'rgba(0,255,0,0.2)'
130-
131-
};
132-
13389
/**
13490
* Speed at which this layer scrolls horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do).
13591
* @property {number} scrollFactorX
@@ -173,6 +129,7 @@ Phaser.TilemapLayerGL = function (game, tilemap, index, width, height) {
173129
* @private
174130
*/
175131
var tileset = this.layer.tileset || this.map.tilesets[0];
132+
176133
this._mc = {
177134

178135
// Used to bypass rendering without reliance on `dirty` and detect changes.
@@ -198,7 +155,8 @@ Phaser.TilemapLayerGL = function (game, tilemap, index, width, height) {
198155

199156
// Cached tilesets from index -> Tileset
200157
tilesets: []
201-
};
158+
159+
}
202160

203161
/**
204162
* The rendering mode (used by PIXI.Tilemap). Modes are: 0 - render entire screen of tiles, 1 - render entire map of tiles
@@ -230,41 +188,34 @@ Phaser.TilemapLayerGL = function (game, tilemap, index, width, height) {
230188
this._results = [];
231189

232190
// get PIXI textures for each tileset source image
233-
var baseTexture = new PIXI.BaseTexture( tileset.image );
191+
var baseTexture = new PIXI.BaseTexture(tileset.image);
192+
234193
PIXI.Tilemap.call(this, new PIXI.Texture(baseTexture), this.map.width, this.map.height, this._mc.tileset.tileWidth, this._mc.tileset.tileHeight, this.layer);
235194

236195
Phaser.Component.Core.init.call(this, game, 0, 0, null, null);
237196

238197
// must be set *after* the Core.init
239198
this.fixedToCamera = true;
240-
};
241199

200+
};
242201

243202
// constructor: extends PIXI.Tilemap
244203
Phaser.TilemapLayerGL.prototype = Object.create(PIXI.Tilemap.prototype);
245204
Phaser.TilemapLayerGL.prototype.constructor = Phaser.TilemapLayerGL;
246205

247-
248-
// only one Phaser component used
206+
// Only one Phaser component used
249207
Phaser.Component.Core.install.call(Phaser.TilemapLayerGL.prototype, [
250208
'FixedToCamera'
251209
]);
252210

253-
254-
// redirect method prototypes (TODO: not needed? I'm not sure...)
255211
Phaser.TilemapLayerGL.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
256-
Phaser.TileSprite.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate;
257-
Phaser.TileSprite.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate;
258-
Phaser.TileSprite.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
259-
Phaser.TileSprite.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
260-
261212

262213
/**
263214
* Automatically called by World.preUpdate.
264215
*
265216
* @method Phaser.TilemapLayerGL#preUpdate
266217
*/
267-
Phaser.TilemapLayerGL.prototype.preUpdate = function() {
218+
Phaser.TilemapLayerGL.prototype.preUpdate = function () {
268219

269220
return this.preUpdateCore();
270221

@@ -297,8 +248,6 @@ Phaser.TilemapLayerGL.prototype.postUpdate = function () {
297248
*/
298249
Phaser.TilemapLayerGL.prototype.destroy = function() {
299250

300-
PIXI.CanvasPool.remove(this);
301-
302251
Phaser.Component.Destroy.prototype.destroy.call(this);
303252

304253
};
@@ -520,6 +469,7 @@ Phaser.TilemapLayerGL.prototype.getRayCastTiles = function (line, stepRate, coll
520469
{
521470
var tile = tiles[i];
522471
var coord = coords[t];
472+
523473
if (tile.containsPoint(coord[0], coord[1]))
524474
{
525475
results.push(tile);
@@ -560,6 +510,7 @@ Phaser.TilemapLayerGL.prototype.getTiles = function (x, y, width, height, collid
560510
// Convert the pixel values into tile coordinates
561511
var tx = Math.floor(x / (this._mc.cw * this.scale.x));
562512
var ty = Math.floor(y / (this._mc.ch * this.scale.y));
513+
563514
// Don't just use ceil(width/cw) to allow account for x/y diff within cell
564515
var tw = Math.ceil((x + width) / (this._mc.cw * this.scale.x)) - tx;
565516
var th = Math.ceil((y + height) / (this._mc.ch * this.scale.y)) - ty;
@@ -598,6 +549,7 @@ Phaser.TilemapLayerGL.prototype.getTiles = function (x, y, width, height, collid
598549
Phaser.TilemapLayerGL.prototype.resetTilesetCache = function () {
599550

600551
this._mc.tilesets = [];
552+
601553
};
602554

603555
/**
@@ -652,8 +604,6 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
652604
var tw = this._mc.tileWidth;
653605
var th = this._mc.tileHeight;
654606

655-
// var lastAlpha = NaN;
656-
657607
offx = offx || 0;
658608
offy = offy || 0;
659609

@@ -664,6 +614,7 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
664614
left = Math.max(0, left);
665615
right = Math.min(width - 1, right);
666616
}
617+
667618
if (top <= bottom)
668619
{
669620
top = Math.max(0, top);
@@ -684,30 +635,28 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
684635
// xmax/ymax - remaining cells to render on column/row
685636
var tx, ty, x, y, xmax, ymax;
686637

687-
//context.fillStyle = this.tileColor;
688-
689-
for (y = normStartY, ymax = bottom - top, ty = baseY;
690-
ymax >= 0;
691-
y++, ymax--, ty += th)
638+
for (y = normStartY, ymax = bottom - top, ty = baseY; ymax >= 0; y++, ymax--, ty += th)
692639
{
693-
694-
if (y >= height) { y -= height; }
640+
if (y >= height)
641+
{
642+
y -= height;
643+
}
695644

696645
var row = this.layer.data[y];
697646

698-
for (x = normStartX, xmax = right - left, tx = baseX;
699-
xmax >= 0;
700-
x++, xmax--, tx += tw)
647+
for (x = normStartX, xmax = right - left, tx = baseX; xmax >= 0; x++, xmax--, tx += tw)
701648
{
702-
703-
if (x >= width) { x -= width; }
649+
if (x >= width)
650+
{
651+
x -= width;
652+
}
704653

705654
var tile = row[x];
706655

707656
if (!tile || tile.index < 0)
708657
{
709658
// skipping some tiles, add a degenerate marker into the batch list
710-
this._mc.tileset.addDegenerate( this.glBatch );
659+
this._mc.tileset.addDegenerate(this.glBatch);
711660
continue;
712661
}
713662

@@ -724,7 +673,7 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
724673
}
725674

726675
// at end of each row, add a degenerate marker into the batch drawing list
727-
this._mc.tileset.addDegenerate( this.glBatch );
676+
this._mc.tileset.addDegenerate(this.glBatch);
728677
}
729678

730679
};
@@ -749,13 +698,14 @@ Phaser.TilemapLayerGL.prototype.renderFull = function () {
749698
var cw = this._mc.cw;
750699
var ch = this._mc.ch;
751700

752-
var left = Math.floor( (scrollX - (cw - tw)) / tw );
753-
var right = Math.floor( (renderW - 1 + scrollX) / tw );
754-
var top = Math.floor( (scrollY - (ch - th)) / th );
755-
var bottom = Math.floor( (renderH - 1 + scrollY) / th );
701+
var left = Math.floor((scrollX - (cw - tw)) / tw);
702+
var right = Math.floor((renderW - 1 + scrollX) / tw);
703+
var top = Math.floor((scrollY - (ch - th)) / th);
704+
var bottom = Math.floor((renderH - 1 + scrollY) / th);
756705

757706
this.glBatch = [];
758707
this.renderRegion(scrollX, scrollY, left, top, right, bottom, 0, -(ch - th));
708+
759709
};
760710

761711
/**
@@ -787,8 +737,7 @@ Phaser.TilemapLayerGL.prototype.render = function () {
787737
var shiftX = mc.scrollX - scrollX; // Negative when scrolling right/down
788738
var shiftY = mc.scrollY - scrollY;
789739

790-
if (!redrawAll &&
791-
shiftX === 0 && shiftY === 0)
740+
if (!redrawAll && shiftX === 0 && shiftY === 0)
792741
{
793742
// No reason to rebuild batch, looking at same thing and not invalidated.
794743
return;

0 commit comments

Comments
 (0)