Sign in to follow this  

Easy Way to Mask Sprite

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

This topic is 3723 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this