Render tilemap when camera outside of world bounds, layer wrapping #851
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. :-)