Jump to content
  • Advertisement
Sign in to follow this  
WebsiteWill

Easy Way to Mask Sprite

This topic is 4095 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

Good morning: Is there an easy way to mask a sprite to a rectangle? Say I have a sprite that is 100 x 100 units and I have an opening of 50 x 50 units. Is there a way to render the 100 x 100 sprite blut mask off all except the visible area (only show the 50 x 50 visible region)? Imagine this for a UI element where a child element is larger than a parent so we want to clip the child to the parents visible area. I am using SpriteBatch BTW. Thanks, Webby

Share this post


Link to post
Share on other sites
Advertisement
Yeah, thanks Name but won't that require me to start an entire new batch for every window (or parent->child) branch that I draw?

And do you think this would be efficient enough for a UI?

This may actually be a better approach to what I am doing now which is basically resizing my child rectangles AND source rectangles to fit into the visible area of the parent. A long series of computations for such a trivial task. I'll try this out to see how it works.

Thanks for this and any more input.

Webby

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!