Question

I've got a problem. Using SpriteBatch, I can only draw a rectangle area from my source Texture2D.

Please, help me to find the way, how I can draw polygon or circle area from my source texture. I'm creating 2d sprite game.

Thanks in advance, Denis

Était-ce utile?

La solution

You could construct this shapes with dynamic vertices, like building your own shapes [1] But if you just want to draw any non rectangular shapes it would be much easier if you just use transparency. So you will still take a rectangular region from your texture but only the circle/polygon is visible. This can be done easily by using png ord tga with baked in transparency. There are also a lot of qeustions dealing with this on SO: [2] [3]

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top