Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a simple board game. In the game there is a fixed background called myTexture and others are textureGoat and textureTiger whicha are to be placed on top of the background(myTexture). But i am having problem that fourth and fifth component is not displaying however, the sixth component( i.e. myTexture) is appearing. Here is my code, please look at it

    protected override void Draw(GameTime gameTime)

        // TODO: Add your drawing code here
        spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

        //placing tiger
        spriteBatch.Draw(textureTiger, new Rectangle(22, 25, 50, 50), Color.White);//first component
        spriteBatch.Draw(textureTiger, new Rectangle(22, 407, 50, 50), Color.White);//second component

        spriteBatch.Draw(textureTiger, new Rectangle(422, 25, 50, 50), Color.White);//third component
        spriteBatch.Draw(textureTiger, new Rectangle(422, 407, 50, 50), Color.White);//fourth component

        //placing goat
        spriteBatch.Draw(textureGoat, new Rectangle(125, 110, 50, 50), Color.White);//fifth component

        //placing background
        spriteBatch.Draw(myTexture, new Rectangle(0, 0, 500, 500), Color.White);//sixth component

share|improve this question
is the third showing? – Valmond Oct 3 '12 at 7:45
The 6th texture is drawn over the entire region and on top of your other textures. Does this texture contain anything in its lower right part, where you are rendering your 4th texture? Also, please include a screenshot so we can get a better clue of what it looks like. – Aaron Kabashi Oct 3 '12 at 7:57
I'm agreeing with Aaron here, your board texture is drawn last (see's_algorithm) so it covers the other images. If you're seeing some of the Goats/Tigers I'm guessing your board has some alpha somewere? Also, you shouldn't need to pass any parameters to spriteBatch.Begin(); – Jonathan Connell Oct 3 '12 at 8:17
all: sorry for delay in replying... @Valmond:yes third is showing – user1090751 Oct 3 '12 at 8:47
@Aaron: yes it contains the fourth element.. u can check by coordinates.. rendering textureTiger as shown in code – user1090751 Oct 3 '12 at 8:50
up vote 0 down vote accepted

you are drawing background last, thus covering everything drawn before.

when you use immediate sorting (i.e. you don't explicitly specify the z-order), you need to draw from bottom to top, as if you were layering transparent paper, where each Draw call is a new layer. you draw background first, then what is supposed to be on background second, etc..., so if your comments mean that "first component" is supposed to be topmost, you need to completely reverse the order of your draw calls.

share|improve this answer

Since you are using BackToFront sort mode you might want to use this draw method;

SpriteBatch.Draw (Texture2D, Vector2, Nullable, Color, Single, Vector2, Vector2, SpriteEffects, Single)

where the last element is the "Sort Depth". This is the parameter that will be used by your sprite batch to choose the order in which to draw things. Since the draw method you are using doesn't set the "Sort Depth" value all sprites will be drawn in the same order you called draw in.

As an alternative, you can simply change the order in which you are calling Draw for each sprite, with objects at the back being drawn first so they don't get drawn over the top.


BackToFront is the sort order recommended for drawing sprites which have some transparency. If your textures have no transparent areas then you will want to use FrontToBack. Also, if you have some with no transparency and some with transparency, you might consider drawing the non-transparent ones first with a sort mode set to FrontToBack and then draw the transparent ones with the sort mode set to BackToFront. Unless performance becomes an issue, I would stick with BackToFront for all sprites and set the "Sort Depth". You can always change it later.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.