I created a SpawnPoint object in my Tiled map and placed it. Inside of Visual Studio, I draw my little sprite character’s position at map.Objects[0].Object[0].Position, which is the location of the Spawn Point. But when the game loads, he’s not where I want him, but when I debug the project, it says he is. I’m assuming this is because the Tiled map is not drawn perfectly to my screen so the locations in the simulator are different than in the Tiled Map. How do I fix this?
The way the map is scaled to the screen is controled by the viewMatrix
and projectionMatrix
passed into the Draw
method.
Take a look at the Tiled demo code to see how it works.
var viewMatrix = _camera.GetViewMatrix();
var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0f, -1f);
_mapRenderer.Draw(_map, ref viewMatrix, ref projectionMatrix, _customEffect);