Monogame Extended: Scaling a Tiled Map with no camera

Greetings all:

I’ve been able to import and render a Tiled Map thanks to Monogame Extended libraries. Yet, the original image is quite small (16px16p), and I wish to be able to play around with some scaling. Most of the things I’ve found out at the web / forums goes around working with an already implemented camera, which I’m not using right now.

Some places suggest using a “Matrix.CreateScale(Vector3(x,y,z))” in the “SpriteBatch.Begin()” method. Yet, If I implement it, the map is not being scaled.

This is the code I’m using:

_spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Matrix.CreateScale(Vector3(2,2,0)));
_tiledMapRenderer.Draw(_tiledMap.GetLayer(“Floor”), null, null, null, 0);
_animation.Draw(spritebatch, _location, tint);
_spriteBatch.End();

Thanks a lot for anyone willing to give me a hand in this issue.

p.s. the animated sprite does not scale either.
Btw … could anyone please give me a hint in how to format my code here at the post? Thanks :slight_smile:

never set your scale to zero,. try 2,2,1 not Matrix.CreateScale(Vector3(2,2,0)));

When you do Matrix.Scale(0,…), it will make it invisible on that axis.

Even if youre doing a 2d game, in monogame, always set it to 1 if not needing Z.

1 Like

Hello @shmellyorc … thanks for the reply!

I’ve done your suggestion and, if I put in the: _spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Matrix.CreateScale(Vector3(2,2,1))); directly when I’m calling for the Sprite Draw(), (being static or animated), it actually scales.

However, for the Tiled Map with the tileRenderer it is another story… after working all day long, I finally solved that it is not possible to “scale” (rather say, zoom), the map. So, I’ve worked in implementing the camera. Now, with the camera working (and following the char), the scale Matrix is replaced with the viewportAdapter of the Camera:

This is needed to be used when Drawing the tiledMap: _tiledMapRenderer.Draw(_tiledMap.GetLayer(“Floor”), _camera.GetViewMatrix());

and at the Sprite Draw(): _spriteBatch.Begin(transformMatrix: transformMatrix);

My final reference was: Cameras | MonoGame.Extended if anyone else need it.