Skip to content

Commit e923e23

Browse files
committed
TilemapLayers can now be used with an unbounded camera (a camera that can move beyond the world boundaries). Currently, when an unbounded camera moves outside of the world, tilemaps start acting weird because they only render themselves strictly within the world limits. With this change, the tilemap will continue scrolling and show empty space beyond its edge (thanks @jotson phaserjs#851)
TilemapLayer.wrap property - if true the map is rendered as if it is on the surface of a toroid (donut) instead of a plane. This allows for games that seamlessly scroll from one edge to the opposite edge of the world without noticing the transition. Note that the World size must match the Map size (thanks @jotson phaserjs#851)
1 parent fddd1e9 commit e923e23

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Version 2.0.6 - "Jornhill" - -in development-
101101
* Sprite.updateCrop is available if you wish to update an externally referenced crop rectangle.
102102
* Sprites and Images now have their own textures objects, they are no longer references to those stored in the global Pixi.TextureCache. This allows you to redefine the texture frame dynamically without messing up any other Sprites in your game, such as via cropping. They still share global Base Textures, so image references are kept to a minimum.
103103
* Sprite.resetFrame will revert the Sprites texture frame back to its defaults dimensions. This is called when you call Sprite.crop with no rectangle, to reset the crop effect, but can be userful in other situations so we've left it as a public method.
104+
* TilemapLayers can now be used with an unbounded camera (a camera that can move beyond the world boundaries). Currently, when an unbounded camera moves outside of the world, tilemaps start acting weird because they only render themselves strictly within the world limits. With this change, the tilemap will continue scrolling and show empty space beyond its edge (thanks @jotson #851)
105+
* TilemapLayer.wrap property - if true the map is rendered as if it is on the surface of a toroid (donut) instead of a plane. This allows for games that seamlessly scroll from one edge to the opposite edge of the world without noticing the transition. Note that the World size must match the Map size (thanks @jotson #851)
104106

105107

106108
### Bug Fixes

build/phaser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,6 +4727,7 @@ declare module Phaser {
47274727
textureFrame: Phaser.Frame;
47284728
tileColor: string;
47294729
type: number;
4730+
wrap: boolean;
47304731

47314732
getRayCastTiles(line: Phaser.Line, stepRate?: number, collides?: boolean, interestingFace?: boolean): Phaser.Tile[];
47324733
getTiles(x: number, y: number, width: number, height: number, collides?: boolean, interestingFace?: boolean): Phaser.Tile[];

src/tilemap/TilemapLayer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
156156
*/
157157
this.rayStepRate = 4;
158158

159+
/**
160+
* @property {boolean} wrap - Flag controlling if the layer tiles wrap at the edges. Only works if the World size matches the Map size.
161+
* @default false
162+
*/
163+
this.wrap = false;
164+
159165
/**
160166
* @property {object} _mc - Local map data and calculation cache.
161167
* @private
@@ -185,12 +191,6 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
185191

186192
};
187193

188-
/**
189-
* @property {boolean} wrap - Flag controlling whether the layer tiles wrap at the edges
190-
* @default false
191-
*/
192-
this.wrap = false;
193-
194194
/**
195195
* @property {array} _results - Local render loop var to help avoid gc spikes.
196196
* @private

0 commit comments

Comments
 (0)