|
10 | 10 | * |
11 | 11 | * TileSprites have no input handler or physics bodies by default, both need enabling in the same way as for normal Sprites. |
12 | 12 | * |
| 13 | +* You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background |
| 14 | +* that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` |
| 15 | +* property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will |
| 16 | +* consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to |
| 17 | +* adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. |
| 18 | +* |
13 | 19 | * An important note about texture dimensions: |
14 | 20 | * |
15 | | -* When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should be |
| 21 | +* When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should ideally be |
16 | 22 | * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etch pixels width by height). If the texture isn't a power of two |
17 | 23 | * it will be rendered to a blank canvas that is the correct size, which means you may have 'blank' areas appearing to the right and |
18 | 24 | * bottom of your frame. To avoid this ensure your textures are perfect powers of two. |
@@ -77,7 +83,9 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) { |
77 | 83 | */ |
78 | 84 | this._scroll = new Phaser.Point(); |
79 | 85 |
|
80 | | - PIXI.TilingSprite.call(this, PIXI.TextureCache['__default'], width, height); |
| 86 | + var def = game.cache.getImage('__default', true); |
| 87 | + |
| 88 | + PIXI.TilingSprite.call(this, new PIXI.Texture(def.base), width, height); |
81 | 89 |
|
82 | 90 | Phaser.Component.Core.init.call(this, game, x, y, key, frame); |
83 | 91 |
|
|
0 commit comments