gx10001
gx10001

Reputation: 155

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!

Upvotes: 3

Views: 3218

Answers (3)

Mickäel A.
Mickäel A.

Reputation: 9357

If the portion of the texture you want to see in the circle is not meant to change during execution, the easiest way is to open Photoshop, make what you want, export it as an image and then load it in a Texture or a Sprite object in your code.

But this can also be done at runtime, via OpenGL using a Stencil test. This is the only solution if the portion displayed in the circle will have to be alterable during execution.

Upvotes: 2

noone
noone

Reputation: 19776

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.

Upvotes: 5

Pranav008
Pranav008

Reputation: 1223

pixmap use this link if u are using other than .png format for your images

Apart form it if you are using png images then just draw the cirlce. Outside the circle will remain transparent.

Upvotes: 1

Related Questions