craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 325 forks source link

Tile Map Tutorial places map (tile at (0,0) in the center of the screen #928

Open dblhack opened 3 months ago

dblhack commented 3 months ago

The sample tutorial for version 4.0 loads tile map so that the map is offset from position (0,0) of the screen. Using the same code base as the sample, I load my tile map and the upper left of my map is in the center of the screen. See attached screen shot. Tile Map not positioned at (0,0) of screen

I also uploaded a screen shot from the actual tutorial. I fully expect the map start at position (0,0).Tile Sample Output

It could be I totally don't understand the code, but since my map has objects embedded in it and I need to create those objects at the location they were placed in the map, I don't see how to create them with the offset.

dblhack commented 3 months ago

I believe the issue is cause from using the Camera.LookAt() method.

protected override void Update(GameTime gameTime) { _tiledMapRenderer.Update(gameTime);

MoveCamera(gameTime);
_camera.LookAt(_cameraPosition); // <<<----------This is the issue, always puts origin in center

base.Update(gameTime);

}