How to use Orthographic camera in MonoGame?

Started by
0 comments, last by GoldSpark 1 year, 11 months ago

So I am trying to make use of orthographic camera for my 2D game using MonoGame. It is my first time using it and whenever I use orthographic camera nothing shows up on the screen and I don't know why. I've been messing around with matrices a lot to try to show it on the screen but it never shows up.

So basically all I do is pass matrix to transformMatrix: in _spriteBatch.Begin(transformMatrix: ) and that is all:

So this is without the transformMatrix:

 protected override void Draw(GameTime gameTime)
    {
        
        GraphicsDevice.Clear(Color.CornflowerBlue);

        
        _spriteBatch.Begin();
        dropShipAnim.Draw(_spriteBatch, new Vector2(50, 50), gameTime);
        _spriteBatch.End();

        // TODO: Add your drawing code here

        base.Draw(gameTime);
    }

and this is with transformMatrix:

protected override void Draw(GameTime gameTime)
    {
        
        GraphicsDevice.Clear(Color.CornflowerBlue);

        Matrix ortho = Matrix.CreateOrthographicOffCenter(0, 100, 100, 0, 0, 100);
        _spriteBatch.Begin(transformMatrix: ortho);
        dropShipAnim.Draw(_spriteBatch, new Vector2(50, 50), gameTime);
        _spriteBatch.End();

        // TODO: Add your drawing code here

        base.Draw(gameTime);
    }

I would be very grateful if someone would explain to me what am I doing wrong.

Ayy lmao

This topic is closed to new replies.

Advertisement