Skip to content

Commit dac6228

Browse files
committed
TileSprite now uses GetPowerOfTwo function to save some lines of code
1 parent b0a1b54 commit dac6228

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

v3/src/gameobjects/tilesprite/TileSprite.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
var CanvasPool = require('../../dom/CanvasPool');
12
var Class = require('../../utils/Class');
2-
var GameObject = require('../GameObject');
33
var Components = require('../components');
4+
var GameObject = require('../GameObject');
5+
var GetPowerOfTwo = require('../../math/pow2/GetPowerOfTwo');
46
var TileSpriteRender = require('./TileSpriteRender');
5-
var CanvasPool = require('../../dom/CanvasPool');
67

78
var TileSprite = new Class({
89

@@ -44,28 +45,12 @@ var TileSprite = new Class({
4445
this.setSize(width, height);
4546
this.setOrigin();
4647

47-
this.potWidth = this.frame.width;
48-
this.potHeight = this.frame.height;
48+
this.potWidth = GetPowerOfTwo(this.frame.width);
49+
this.potHeight = GetPowerOfTwo(this.frame.height);
4950
this.canvasPattern = null;
5051

5152
if (resourceManager)
5253
{
53-
this.potWidth--;
54-
this.potWidth |= this.potWidth >> 1;
55-
this.potWidth |= this.potWidth >> 2;
56-
this.potWidth |= this.potWidth >> 4;
57-
this.potWidth |= this.potWidth >> 8;
58-
this.potWidth |= this.potWidth >> 16;
59-
this.potWidth++;
60-
61-
this.potHeight--;
62-
this.potHeight |= this.potHeight >> 1;
63-
this.potHeight |= this.potHeight >> 2;
64-
this.potHeight |= this.potHeight >> 4;
65-
this.potHeight |= this.potHeight >> 8;
66-
this.potHeight |= this.potHeight >> 16;
67-
this.potHeight++;
68-
6954
this.renderer = scene.sys.game.renderer;
7055
var gl = scene.sys.game.renderer.gl;
7156

0 commit comments

Comments
 (0)