Skip to content

Commit b9f62e7

Browse files
committed
You can now pass a TilemapLayer as a Texture to a TileSprite. A limitation of this is that if you pass it to a TileSprite it will make a fill pattern from the TilemapLayer at that instant it's passed, and it won't keep track of the layer in future should it update (thanks @jdnichollsc phaserjs#1989)
1 parent e4a505d commit b9f62e7

6 files changed

Lines changed: 12 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
329329
* BitmapData has a new property `frameData` which is a Phaser.FrameData container instance. It contains a single Frame by default, matching the dimensions of the entire BitmapData, but can be populated with additional frames should you wish to create animations from dynamic BitmapData textures.
330330
* FrameData.destroy will nullify the local arrays used to contain Frame instances.
331331
* SoundManager.muteOnPause is a new boolean that allows you to control if the Sound system gets muted automatically when a Phaser game pauses, such as when it loses focus. You may need to set this to `false` if you wish to control the audio system from outside of your Phaser game, i.e. from DOM buttons or similar (#2382)
332+
* You can now pass a TilemapLayer as a Texture to a TileSprite. A limitation of this is that if you pass it to a TileSprite it will make a fill pattern from the TilemapLayer at that instant it's passed, and it won't keep track of the layer in future should it update (thanks @jdnichollsc #1989)
332333

333334
### Updates
334335

src/gameobjects/GameObjectCreator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Phaser.GameObjectCreator.prototype = {
168168
* @param {number} y - The y coordinate (in world space) to position the TileSprite at.
169169
* @param {number} width - The width of the TileSprite.
170170
* @param {number} height - The height of the TileSprite.
171-
* @param {string|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
171+
* @param {string|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData.
172172
* @param {string|number} frame - If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
173173
* @return {Phaser.TileSprite} The newly created tileSprite object.
174174
*/

src/gameobjects/GameObjectFactory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Phaser.GameObjectFactory.prototype = {
250250
* @param {number} y - The y coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in.
251251
* @param {number} width - The width of the TileSprite.
252252
* @param {number} height - The height of the TileSprite.
253-
* @param {string|Phaser.BitmapData|Phaser.Video|PIXI.Texture} key - The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.
253+
* @param {string|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData.
254254
* @param {string|number} [frame] - If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name.
255255
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
256256
* @return {Phaser.TileSprite} The newly created TileSprite object.

src/gameobjects/TileSprite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* @param {number} y - The y coordinate (in world space) to position the TileSprite at.
5454
* @param {number} width - The width of the TileSprite.
5555
* @param {number} height - The height of the TileSprite.
56-
* @param {string|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a RenderTexture, PIXI.Texture or BitmapData.
56+
* @param {string|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData.
5757
* @param {string|number} frame - If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
5858
*/
5959
Phaser.TileSprite = function (game, x, y, width, height, key, frame) {

src/gameobjects/components/LoadTexture.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ Phaser.Component.LoadTexture.prototype = {
103103
key.onChangeSource.add(this.resizeFrame, this);
104104
this.texture.valid = valid;
105105
}
106+
else if (Phaser.Tilemap && key instanceof Phaser.TilemapLayer)
107+
{
108+
// this.customRender = true;
109+
110+
this.setTexture(PIXI.Texture.fromCanvas(key.canvas));
111+
}
106112
else if (key instanceof PIXI.Texture)
107113
{
108114
this.setTexture(key);

src/pixi/extras/TilingSprite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo, re
344344
var texture = this.texture;
345345
var frame = texture.frame;
346346

347-
var targetWidth = this._frame.sourceSizeW;
348-
var targetHeight = this._frame.sourceSizeH;
347+
var targetWidth = this._frame.sourceSizeW || this._frame.width;
348+
var targetHeight = this._frame.sourceSizeH || this._frame.height;
349349

350350
var dx = 0;
351351
var dy = 0;

0 commit comments

Comments
 (0)