Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circle shaped texture libGdx

I've been searching for answer for about 2 hours now and I haven't found my desired answer. My question is, Is it possible, and how, to draw a circle-shaped texture, so that outside the circle, texture would be transparent, is it even possible?

Thanks in advance! This site has been a great help so far!

like image 383
gx10001 Avatar asked Feb 02 '26 09:02

gx10001


1 Answers

The easiest way is to open a program like Photoshop and make an image with an alpha-channel. That means: Start with a completely transparent image and draw a circle on it. Then save it as .png

You can then just load it in your game and render it using a SpriteBatch. It (or better your graphics card) knows how to handle the alphachannel and will keep everything but the circle completely invisible.

This way you do not have to manipulate any pixmaps at runtime and you are not limited to simple shapes like circles.

like image 78
noone Avatar answered Feb 05 '26 08:02

noone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!