|
| 1 | +var CanvasPool = require('../../dom/CanvasPool'); |
1 | 2 | var Class = require('../../utils/Class'); |
2 | | -var GameObject = require('../GameObject'); |
3 | 3 | var Components = require('../components'); |
| 4 | +var GameObject = require('../GameObject'); |
| 5 | +var GetPowerOfTwo = require('../../math/pow2/GetPowerOfTwo'); |
4 | 6 | var TileSpriteRender = require('./TileSpriteRender'); |
5 | | -var CanvasPool = require('../../dom/CanvasPool'); |
6 | 7 |
|
7 | 8 | var TileSprite = new Class({ |
8 | 9 |
|
@@ -44,28 +45,12 @@ var TileSprite = new Class({ |
44 | 45 | this.setSize(width, height); |
45 | 46 | this.setOrigin(); |
46 | 47 |
|
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); |
49 | 50 | this.canvasPattern = null; |
50 | 51 |
|
51 | 52 | if (resourceManager) |
52 | 53 | { |
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 | | - |
69 | 54 | this.renderer = scene.sys.game.renderer; |
70 | 55 | var gl = scene.sys.game.renderer.gl; |
71 | 56 |
|
|
0 commit comments