• Advertisement
Sign in to follow this  

Drawing a sprite in a rect.

This topic is 3184 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Edit - unhelpful stuff deleted

[Edited by - Alatar on June 4, 2009 1:08:29 AM]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Edit - unhelpful stuff deleted

[Edited by - Alatar on June 4, 2009 1:32:39 AM]

Share this post


Link to post
Share on other sites
How would I downscale a sprite without a destination rect? What I'm basically saying is lets say I have an image that's like 1024x800 and I want to disply it as a small 306x200 model on screen, without a dest rect I would have to basically do all the things I said in the last post.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement