Drawing a sprite in a rect.
Hi, I've recently switched from using textured quads for my 2d game to using sprites, surprisingly though I did not find a place for Destination Rect in the sprite's Draw call, and I happen to need that feature. Basically is there any way to draw a sprite in a specified rect.
P.S I know that you can probably use some sort of an equation to figure out the scaling and the translate factors that would make it the size of a given rect, but is there a more elegant solution? Thanks
I think it worked because you used the same size image. What I'm guessing is that the scale matrix will scale the image from the center outwards, meaning that it would scale in the + and - x directions. So even if I put the pos as the top coordinates of the rect, the scaling will offset it. The only way I think this might work is if I set the center to the top left corner of image, set the position as the top left corner of the dest rect, then come up with an equation that would give me a scale factor depending how far the right edge of the image is from the right edge of the dest rect. But this seems a little too much, all this work just to draw a sprite in one spot, and I plan to have lots (of animated) sprites all over the place, I might as well stick with textured quads... Anyways is this the only way? I can't believe DX guys left out such an obvious function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement