Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Level depth in various draw functions?

$
0
0

@Inuma wrote:

In animatedSprite.cs I have:

 public void Draw(SpriteBatch spriteBatch, Vector2 location)
    {
        int width = Texture.Width / Columns;
        int height = Texture.Height / Rows;
        int row = (int)((float)currentFrame / (float)Columns);
        int column = currentFrame % Columns;
         Rectangle sourceRectangle = new Rectangle(width * column, height * row, width, height);
     Rectangle  destinationRectangle = new Rectangle((int)location.X, (int)location.Y, 120, 140);
        if (Game1.przelacznik_w_bezruchu == true) { sourceRectangle = new Rectangle(0, 0, width, height); }
        spriteBatch.Begin();
        spriteBatch.Draw(Texture, destinationRectangle, sourceRectangle, Color.White);
        spriteBatch.End();
          }

In GameScene.cs:

  private void DrawGame()
    {
        spriteBatch.Begin();
        spriteBatch.Draw(floor1, rec_floor1, color1);
        spriteBatch.Draw(floor2, rec_floor2, color1);
        spriteBatch.Draw(house1, rec_house1,color1);
        spriteBatch.End();
    }

I want the floor and the house to be on a lower level than the sprite, so that they do not obscure the sprite. But I dont know how to assign depth levels to textures.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles