photonstorm/phaser — pull request #851 by jotson (2014-05-27 22:08:58+00:00)
Title: Render tilemap when camera outside of world bounds, layer wrapping

This changes TilemapLayer rendering so that it is possible to use them 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.

I also added a "wrap" property. When that is 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.

Here's an example of this in action. In this example, the world, the map, and the stage are all 640x640 pixels: https://dl.dropboxusercontent.com/u/7063628/phaser-wrap/example.html

This is compatible with the current implementation with bounded cameras. The camera stops at the world edge and the game works exactly as before. Also, the "wrap" function isn't perfect: it only works correctly when the map is the same size as the world.

The renderDebug diff shows a bunch of changes because of an extra indent from adding `if (this._column)`.

Not sure if this is a good idea or not. But I need it for a game I'm working on so here it is. :-)