I am currently designing a simple 2D breakout game using Direct3D. I created a custom sprite class that allows easy drawing of 2d graphics.
However, my problem started when I decided to scale some of my sprites.
When i call Sprite.Draw2D (or even Sprite.Draw), and I specify a rectangle for the DestinationRectangle parameter that is larger than the size of the texture (thus, scaling the sprite). If i were to then draw this sprite on the screen at position x=10, y=10, it really isn't at that position! it is more like x=20, y=20! This only seems to happen when I scale the sprite.
How do i scale a sprite and keep it at the position i specify on the screen

weird sprite positioning behaviour
naeem khan
The rectangle that you pass to the Draw method is the bit of the texture you want to use. You want to create a matrix and apply your scaling, rotations and transforms to it then use it to set the sprites Transform property. Then call the Draw method.
Vassil Kovatchev
I tried that. I used Sprite.Transform = Matrix.Scaling(2, 2, 1)
But that still wont work. It will scale the sprite, but the position is still different.
Actually I noticed something. I can place the unscaled sprite at pos x=10, y=10; but because i scaled it to a size twice the size, it appears onscreen at position x=20, y=20 even though the Position parameter I pass to the sprite.Draw function is x=10, y=10
Piepens
The transform property is also used to translate the sprite. If you set the position vector of the Draw method to (0,0,0) you're basically saying the top left of the sprite, same with the center vector. So when you're doing your scaling, rotations and translations its with reference to these points.
If can, download the C++ documentation, I know you're not using C++ but the methods are similar and the information is a little bit more detailed. You can never have too much information.
HayArms
One way to do it is to put
float scale = 2.0f;
float posX = 10.0f;
float posY = 10.0f;
Sprite.Transform = Matrix.Scaling(scale, scale, 1);
then pass x = posX/scale and y = posY/scale to your sprite.Draw() function.