1
votes

I'm not sure why this is happening.

Basically I render my tile map to the screen using a Spritebatch with a matrix transformation, and I get this weird tearing thing happening. Tearing Note that everything looks fine when I render using Matrix.Identity.

This is the code that I use to create the Matrix: #region Creating Transformation private void CreateTransformation() { transformation = Matrix.Identity; Vector3 screenCenter = new Vector3 (graphics.Viewport.Width * 0.5f, graphics.Viewport.Height * 0.5f, 0f);

        transformation *= Matrix.CreateTranslation(-screenCenter); 
        transformation *= Matrix.CreateScale(zoom); 
        transformation *= Matrix.CreateTranslation(screenCenter); 
        transformation *= Matrix.CreateTranslation 
            (position.X * zoom, position.Y * zoom, 0f); 

        mustUpdateTransformation = false; 
    } 
    #endregion 

And this is the code that I use to begin the SpriteBatch:

        ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, camera.Transformation); 

And here is the code used to render each tile:

    public void Draw(SpriteBatch batch) 
    { 
        foreach (var layer in MapLayers) 
        { 
            foreach (Tile T in layer) 
            { 
                batch.Draw(T.SpriteSheet.Texture, T.Position, T.SpriteSheet.SourceRectangle(T.TileIndex), Color.White); 
            } 
        } 
    } 

Does anyone know what is happening?

1

1 Answers

1
votes

Fixed, was doing something silly by representing pixel space as floats instead of integers.