Take the 2-minute tour ×

Okay im working on making a tic tac toe game for one of my game development courses using XNA 4.0 I need to place sprites or some other objects so the game can check if the mouse is being clicked in the correct spots. I am going to use transparent sprites as a kind of button. How do I code them to go to these specific x,y coordinates. The game board is drawn on the background, I have all the coordinates to where to place these sprites. I am just stuck on putting the sprites in the correct positions.

share|improve this question

3 Answers 3

SpriteBatch.Draw has a position parameter. Pass in an appropriately-valued Vector2.

share|improve this answer

Well if you check the Draw method you will find a parameter for the position. Check this code sample

Vector2 pos = new Vector2(10, 10);
spriteBatch.Draw(SpriteTexture, pos, Color.White);

This is how you draw a sprite, with SpriteTexture as the image, on the position x10, y10 with the color White to modulate the texture.

You can also find more informations here.

share|improve this answer

Keep in mind that there are many overloaded methods to the Draw method. One you can even pass in rotation information and the like. So .Draw(...) has a lot of functionality you can use beyond just placing a sprite.

share|improve this answer

Your Answer


