0
\$\begingroup\$

On the internet, I saw videos and tutorials about screen scrolling. But those only show how to keep the player always in the center of the camera.

I want my camera to scroll over the level, following the character, only when the character is within the 20% border of the screen.

So, when the player is not close to the edge of the window then the camera stays in place and not follow the player and when the player crosses this "scrolling line" the camera should smoothly follow hit. Let's say that my game window is 1000px wide and 500px high, but the game map is 3000px wide and 3000px high.

\$\endgroup\$
2
  • \$\begingroup\$ I'm wondering what is the difference between SpriteBatch.GraphicsDevice.Viewport.Width and GraphicsDeviceManager.PreferredBackBufferWidtht? \$\endgroup\$
    – Karol
    Jun 10, 2019 at 15:17
  • \$\begingroup\$ You basically answered the question yourself. "when the player is not close to the edge of the window then the camera stays in place" Most mechanisms call an update-function to update the camera respective to the players position. Just add an If-clause to update the position only if the player is out of specified bounds. \$\endgroup\$ Jun 11, 2019 at 10:19

0

You must log in to answer this question.

Browse other questions tagged .