Camera wrap?


#1

I want to achieve this effect:
path3793

That when a camera view (pink) reaches the end of the tilemap (dark pink), the view renders in the amount of offset the tilemap of the opposite side.

Ideas? Thanks!


#2

Hi @Gabriel,
I think Phaser cameras haven’t a specific method for that.
If you only need to replicate the background and static objects, you could draw them in rendertextures and position them when the camera reaches a limit of the game.
This example of infinite scroll uses that concept:

See the Pen [Phaser3] Infinite scroll using 2 renderTexture objects by Juan Jose Capellan (@jjcapellan) on CodePen.

Or maybe the class TileSprite can be useful in your case.
Regards.


#3

You could try something this:
https://labs.phaser.io/edit.html?src=src\game%20objects\tilemap\dynamic\endless%20map.js
However instead of picking random tiles, you just start inserting tiles from the beginning of your make so it appears your camera is wrapping around.


#4

Interesting! Thanks both you guys.

Right now I have the tilemap to stretch all the viewable area and wrap around using TileSprite @jjcapellan and the next step is having the cursor to also wrap around matching the TilemMap to the TileSprite.