How to end Camera movement when map reaches the screen border?

I wonder what is the best way to end the camera player follow when a map layer outer borders reach the visible screen borders?

For example: In the game a player is always shown in the center of the screen because the camera is set to follow the player sprite. Now when a maps left, right (or top or down) end is reached and the map should not scrolled anymore in the visible screen area, the camera player follow should end, so the map stands still and the player is moving to the screen border.

So what is the best way to achieve this in dusk? I mean how to best detect a map layers outer border and compare them to the visible screen?

I am new to dusk so this is just a suggestion:

  1. if you have got a rectangle map, try map.setCameraBounds

  2. if you have non-rectangular map, use map.pixelsToTiles of your player’s position, and check it’s distance to nearest edge, and map.positionCamera manually (not sure how to disable setCameraFocus though)

ref: http://cdn.rawgit.com/GymbylCoding/Dusk-Engine/v0.2/docs/guides/careening-into-dusk.html

map.setCameraBounds was exactly what I was looking for! Thank you bitinn! :slight_smile:

I am new to dusk so this is just a suggestion:

  1. if you have got a rectangle map, try map.setCameraBounds

  2. if you have non-rectangular map, use map.pixelsToTiles of your player’s position, and check it’s distance to nearest edge, and map.positionCamera manually (not sure how to disable setCameraFocus though)

ref: http://cdn.rawgit.com/GymbylCoding/Dusk-Engine/v0.2/docs/guides/careening-into-dusk.html

map.setCameraBounds was exactly what I was looking for! Thank you bitinn! :slight_smile: